PDA

View Full Version : bug Ext.form.CheckBoxField and form.getValues()



mdissel
1 Jul 2007, 11:54 PM
Currently the form.getValues() uses el.dom.value to get the value of the checkbox.. In Firefox 2.x (didn't test IE yet) this returns always "on" when the checkboxstate was initially false and clicked to true by the user, el.dom.checked returns the correct true/false state

And a checkbox is never returned by form.getValues() if the state if false.. I need the false state also when sending the result back to the server.. (and checking for a not-available field is no option)

Thanks

Marco

jack.slocum
2 Jul 2007, 12:36 AM
In Firefox 2.x (didn't test IE yet) this returns always "on" when the checkboxstate was initially false and clicked to true by the user, el.dom.checked returns the correct true/false state.

And a checkbox is never returned by form.getValues() if the state if false.. I need the false state also when sending the result back to the server.. (and checking for a not-available field is no option)

getValues() returns the values as they would be submitted to the server. If you have specified an inputValue in the config, that defaults to "on" for checked. Unchecked checkboxes don't get submitted to the server at all.

mdissel
2 Jul 2007, 1:24 AM
getValues() returns the values as they would be submitted to the server. If you have specified an inputValue in the config, that defaults to "on" for checked. Unchecked checkboxes don't get submitted to the server at all.

Is it possible to change / override the code to include checkboxes that are not checked??

Thanks

Marco

jack.slocum
2 Jul 2007, 3:49 AM
You could do a simple alternative if you are looking for the field.getValue() value instead of what the form sees:


var values = {};
form.items.each(function(f){
values[f.getName()] = f.getValue();
});
// now you have values

mdissel
2 Jul 2007, 11:02 AM
Thanks.. that is exactly what i need. (although i expected this implementation in the form.getValues() function..:-/

Marco

willdudziak
27 Feb 2008, 1:31 PM
me too... very non-intuitive. why would anyone expect a function called 'getvalues' returns a javascript object omitting the boxes that are unchecked?

principle of least surprise anyone?