Forms - enable validation only when submitted data is not empty #60841
Unanswered
FluffyDiscord
asked this question in
Q&A
Replies: 1 comment
-
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I hacked my way using reflection to achieve what I need, but that does not seem right, and I am asking if this is possible to do it in a normal way.
I have collection of translation form types which have their own constraints and required fields. I want to dynamically disable validation for these types (form children) when the submitted data is empty.
Here my amalgamation (using event listener) which works how I want. There's got to be a better way, can anyone help me out please?
I tried to simply re-add the form types using
$event->getForm->add($childIndex, $childType, [...$originalOptions, 'required' => true])
, but that did not work.Beta Was this translation helpful? Give feedback.
All reactions