views:

357

answers:

1

When I post a form using dojo.xhrPost, I get all the fields in my form POSTed except for the value of my dojox.CheckedMultiSelect, no matter what options are selected.

The declaration of my CheckedMultiSelect:

<div dojoType="dojo.data.ItemFileReadStore" jsId="processTypeList" url="json/processtypelist.json.php"></div>
<label for="processTypeSelect">Process Types</label>
<select dojoType="dojox.form.CheckedMultiSelect" name="processTypeSelect" id="processTypeSelect" multiple="true" style="height:166px;" store="processTypeList"></select>

And here is my xhrPost:

<button dojoType="dojox.form.BusyButton" id="logSearchSubmit" busyLabel="Searching..." timeout="5" 
  onclick="dojo.xhrPost({
    url: 'handlers/logsearch.php',
    form: dojo.byId('formSearch'),
    handleAs: 'json'
});">Search</button>

And here is what I get POSTed:

endDate 2009-12-15
postAction  search
processSelect   
searchAttribute none
searchAttributeValue    
startDate   2009-12-15

Any reason why the dojox control value doesn't get posted, though all the values of the dijit controls that are part of my form get posted? The control is right in between the other ones who's values get POSTed, so I know it is within the form.

I just added another button to perform console.log(formSearch.getValues()) instead of the xhrPost and I get the value of the control logged into the console. So obviously dojo is aware of it, but when I do a console.log(dojo.formToJson("formSearch")) I get all the form data except for the the dojox control again.

+2  A: 

I'm guessing it's a bug in CheckedMultiSelect that it doesn't carry over the 'name' attribute from the declared markup to the hidden select widget that would be used in a form submit. The dijit.form widgets have to do this in a fairly kludgy way due to some IE behavior, inserting ${nameAttrSetting} directly into the template (CheckedMultiSelect.html) at the select element. See dijit/form/templates/Button.html for an example.

CheckedMultiSelect inherits from dijit, but needs to replicate this fix in its own template, since it cannot be inherited. If this is the solution, please consider submitting a report and patch to bugs.dojotoolkit.org.

peller
Yes, that appears to be it... The hidden select for the control is: `<select id="processTypeSelect" class="dojoxMultiSelectSelect" dojoattachpoint="containerNode,focusNode" multiple="true" tabindex="0" style="-moz-user-select: none;"/>,` obviously missing the name. Thanks!
Kitson
I opened bug #10544 for this problem. Thanks again for pointing me in the right direction.
Kitson
Thanks for finding this problem and reporting the bug!
peller