Skip to content
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

Option includeDisabled #119

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

fglueck
Copy link

@fglueck fglueck commented Mar 15, 2021

If "true" also disabled :input items are included.

@marioizquierdo
Copy link
Owner

Thank you. Could you elaborate why this option would be useful? We would also need tests to cover the new use-case. I can review the docs and code comments after that.

@fglueck
Copy link
Author

fglueck commented Mar 18, 2021

This option is usefull in follow case.
If you have "default"-values on server side for paramerts/values that are comes from a form than you have a problem if some parameters not allways submited. The same problem you have with not sended checkboxes or not sended select multiple. You can't detect the difference between, is the parameter not sendet or is it switched off/unselected.

generates an empty entry for an empty select multiple element
@@ -50,6 +51,10 @@
if (type === "skip") {
return; // ignore fields with type skip
}
if(obj.multiple) {
type = 'array';
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this check? Maybe we should explain in a comment for clarity

// Filter with the standard W3C rules for successful controls: http://www.w3.org/TR/html401/interact/forms.html#h-17.13.2
return this.name && // must contain a name attribute
!$el.is(":disabled") && // must not be disable (use .is(":disabled") so that fieldset[disabled] works)
(!$el.is(":disabled") || $el.is(":disabled") && opts.includeDisabled) && // must not be disable (use .is(":disabled") so that fieldset[disabled] works)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check seems equivalent to (!$el.is(":disabled") || opts.includeDisabled)

} );
if(!val.length) {
return { name: el.name, el: el }
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when would the array not have a length property? Should that not be factored into the isArray(val) function check?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants