-
Notifications
You must be signed in to change notification settings - Fork 40
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
[DX] Introduce a server-side conditional system (to possibly replace #states
)
#5750
Comments
I updated the summary with a bit more detail. One of the big problems with conditional validation is that the most obvious way to identify form elements is by its key, or an array of parents. We do this for things like With conditional form elements, specifying a full list of parents could be difficult, because we're often assembling only part of a form, such as when building a field widget, or the configuration form for a block. This form partial could be placed in any number of form structures. To solve for this, I think we could introduce relative tree traversal, matching the paradigms used in operating systems. Two periods could mean "up one parent" and one period could mean "relative to myself". Some hypothetical syntax below... Given a controlling element like a checkbox that hide/shows other parts of the form:
Conditionally shown element adjacent to the checkbox:
Conditionally shown element with a different parent:
The |
#states
)#states
)
I really like the idea for this feature. Having been working in UX-related issues and using
Another idea would be to use the
...we could be doing:
|
This came up as an idea in #5348 (comment)
@quicksketch
The
#states
property is a front-end only implementation. The lack of any server-side processing means any hidden fields cannot be required, or special validation handlers need to be added that validate field requireness manually.Proposal
Introduce a new Form API property for designating conditional processing of parts of a form. This property would hide/show elements on the front end (like
#states
does already), but would also conditionally skip processing for hidden parts of the form. Hidden parts of the form would skip:#required
attribute on hidden fields#element_validate
handlers on hidden fields$form_state['values']
for hidden fieldsThe text was updated successfully, but these errors were encountered: