Skip to content

Fix required validation for hidden fields with depends_on conditions#462

Open
fabiSwDevBeg wants to merge 1 commit into
collective:masterfrom
fabiSwDevBeg:fix-required-dependson
Open

Fix required validation for hidden fields with depends_on conditions#462
fabiSwDevBeg wants to merge 1 commit into
collective:masterfrom
fabiSwDevBeg:fix-required-dependson

Conversation

@fabiSwDevBeg

Copy link
Copy Markdown

This commit updates EasyFormForm.extractData to properly handle fields with depends_on conditions (PatternSlLib-style).

Implements evaluate_dependson() to evaluate the depends_on condition of a field.

Adds remove_required() which removes the required flag from fields whose depends_on condition is not satisfied (i.e., hidden fields).

Overrides extractData() to apply remove_required() to all form widgets and group widgets before validation.

Effect:
Hidden fields that are marked as required no longer trigger validation errors, allowing the form to submit successfully when the conditions for showing the field are not met.
Fixes #461

This commit updates EasyFormForm.extractData to properly handle fields with depends_on conditions (PatternSlLib-style).

Implements evaluate_dependson() to evaluate the depends_on condition of a field.

Adds remove_required() which removes the required flag from fields whose depends_on condition is not satisfied (i.e., hidden fields).

Overrides extractData() to apply remove_required() to all form widgets and group widgets before validation.

Effect:
Hidden fields that are marked as required no longer trigger validation errors, allowing the form to submit successfully when the conditions for showing the field are not met.
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.

Field with depends_on condition non satisfied (hidden), required, triggers validation error (collective.easyform 3.2.1, Plone 5.2.14)

1 participant