#10617 closed defect (wontfix)
Programmatically created widgets not in form values
Reported by: | Simon Speich | Owned by: | |
---|---|---|---|
Priority: | high | Milestone: | tbd |
Component: | Dijit | Version: | 1.4.0 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
When accessing the values of form widgets with the method form.attr('value') or form.getValues() only values of programmatically created widgets are returned, whose name attribute was set upon instantiation ignoring declaratively set name attributes:
<form name="frm"> <input type="text" name="test" id="test"/> </form> // does not work // new dijit.form.TextBox({id: 'test'}, 'test'); // console.debug((dojo.toJson(el.attr("value")))); //works: new dijit.form.TextBox({name: 'test'}, 'test'); console.debug((dojo.toJson(el.attr("value"))));
Testcase at http://www.speich.net/projects/programming/dijit-form.php.
I think the declaratively set name attribute should be respected and its confusing that it works only with name and not id attribute. This is related to ticket #10616
Change History (5)
comment:1 Changed 11 years ago by
Component: | General → Dijit |
---|---|
Owner: | anonymous deleted |
comment:2 Changed 11 years ago by
Resolution: | → wontfix |
---|---|
Status: | new → closed |
Perhaps you are asking for Form.get("value") to return anything w/an id, not just stuff with a name. That's just now how Form is intended to work, nor how HTML works either.
comment:3 Changed 11 years ago by
Sorry for not replying sooner (notification e-mail must have gotten lost...) and sorry for the not so well written and confusing test case.
You assumed right that I meant Form.get('value') should return any form element with an id. I know, that a submitted HTML form only sends names, but if you look at the code below you can see, that the current situation is kind of confusing/unsatisfying even if this is the intended behavior.
Maybe creating a TextBox? without setting the name attribute could throw an error or at least you could mention this in the documentation somewhere, that if a form element doesn't contain a name attribute it is not returned?
var frm = new dijit.form.Form({id: 'frm'}); // This textbox1 is not included in returned object from form.attr(value) var textbox1 = new dijit.form.TextBox({id: 'Test1', value: 'Testvalue1'}); // But this one is var textbox2 = new dijit.form.TextBox({id: 'Test2', name: 'Test2', value: 'Testvalue2'}); frm.domNode.appendChild(textbox1.domNode); frm.domNode.appendChild(textbox2.domNode); dojo.place(frm.domNode, 'title', 'after'); alert((dojo.toJson(frm.attr("value"))));
comment:4 Changed 11 years ago by
Good point, I'll update the documentation.
I don't want to disallow TextBox widgets without names because people may be using that "feature" as a way to embed widgets in their Form that they don't want to be part of the form's value.
Your example code above is confusing since you reference el but never set it.
Also, in the ticket summary you say the problem is that "Programmatically created widgets not in form values" but then in the description say the opposite, that "*only* values of programmatically created widgets are returned".
I checked your testcase on the link, where you do:
It returns
{test2: ""}
, which seems fine, since your test2 TextBox has a blank value.Can you attach a test case using the attach file button?