sulu / SuluFormBundle

Form Bundle for handling Dynamic and Symfony Forms in https://sulu.io
MIT License
81 stars 78 forks source link

Freetext fields have required constraints #379

Closed oprichnik closed 5 months ago

oprichnik commented 6 months ago
Q A
Bug? Yes
New Feature? no
Bundle Version 2.5.2
Sulu Version 2.5.10
Browser Version Firefox 125

Actual Behavior

When switching from a field with the "required" radio set, to a "freetext" field, the "required" radio disappears but the behaviour is still there and submitting the form trigger a required error on that field

Expected Behavior

No required constraint on freetext fields

Steps to Reproduce

  1. Create a classic field and set the "required" on.
  2. Switch this field to a "freetext" field
  3. Save the form
  4. Create a page including this form and try to send the form

Possible Solutions

Do not put any constraint on freetext fields

image

alexander-schranz commented 6 months ago

@oprichnik Thank you for the report I think we should do a check here for HiddenType::class to not set hidden fields with a notblank constraint:

https://github.com/sulu/SuluFormBundle/blob/b87895c44c701410fe84f4ddb44cace72b2cee7c/Form/Type/DynamicFormType.php#L117

Do you want to create a pull request for it.

oprichnik commented 6 months ago

Here it is: https://github.com/sulu/SuluFormBundle/pull/380