-
Notifications
You must be signed in to change notification settings - Fork 556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
if item type: 'boolean', issue #41
Comments
Isn't this how this is handled in pure html forms as well? |
thanks for the fix jupe. worked great |
I included the provided patch in 8d3bb01. I initially did that because I thought that validation would fail if the schema key was defined as That second change means that there is no way to define a checkbox that users must check before they proceed (a typical example would the infamous "by clicking here, you agree with our terms of service"). I do not know how to express such a flag in JSON Schema though. |
A recent change (#41) sends unchecked checkboxes as falsy values when the form is submitted (instead of not sending them at all). However, that change does not take into account the fact that checkboxes may be in a "disabled" state. A disabled checkbox must not take part in the construction of the submitted object. Issues typically rise when a checkbox appears in more than one tabs of a "selectfieldset". Fields that are in inactive tabs are correctly flagged as "disabled" but since the code did not check that flag, it would override a possibly checked value with the falsy value of the last occurrence of the checkbox in the tabs of the selectfieldset. Best illustrated with the example JSON Form object below where the "flag" checkbox appears for Choice 1 and Choice 3: { "schema": { "choice": { "type": "string", "title": "Make a choice", "enum": [ "Choice 1", "Choice 2", "Choice 3" ] }, "flag": { "type": "boolean", "title": "Check me up" } }, "form": [ { "type": "selectfieldset", "key": "choice", "items": [ flag, { "type": "section" }, flag ] } ] } If "Choice 1" was selected and the checkbox checked, "flag" was not set in the submitted object.
if checkbox is unchecked and press submit button, uncheck state is not regonized at all because of serializeArray() . There is one fix for jquery ( https://github.com/madrobby/zepto/pull/248/commits ), but i think it is not added to main jQuery branch. One possible way to fix this issue is to add concat just after serializeArray() -->
line: 2138
/* Because serializeArray() ignores unset checkboxes and radio buttons: */
formArray = formArray.concat(
$(':input[type=checkbox]:not(:checked)', this.el).map( function() {
return {"name": this.name, "value": this.checked}
}).get()
);
The text was updated successfully, but these errors were encountered: