You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In case the dependent field has validator on it (like NotNull, NotBlank) an error should appear because the field is added but is empty.
To fix it, we commonly add this in the Controller:
if ($request->isXmlHttpRequest() && $forminstanceof ClearableErrorsInterface) {
$form->clearErrors(true);
}
Maybe is it possible, to retrieve the Request inside the DynamicFormBuilder and check it automatically ?
The text was updated successfully, but these errors were encountered:
I think isXmlHttpRequest() is not going to be a good enough signal to use inside the library - fetch(), for example, does not send the X-Requested-With header that this relies on. We would need some... extra signal to know when to clear - like some method on DynamicFormBuilder where you configure that. But I think it's outside of the scope of what this library should be doing. However, enhancing the documentation to show a real-world example (including this clearing) to the docs would be AWESOME... if you want to open a PR ;)
Yep, I've think about isXmlHttpRequest() and default support it because of usage with the Symfony Form and Symfony Stimulus/Turbo that, I believe, defaultly use XmlRequests.
But, actually in all dependant form I do I put that fragment, then I can see to create a PR that just mention it as a reminder for user.
if ($request->isXmlHttpRequest() && $forminstanceof ClearableErrorsInterface) {
$form->clearErrors(true);
}
In case the dependent field has validator on it (like NotNull, NotBlank) an error should appear because the field is added but is empty.
To fix it, we commonly add this in the Controller:
Maybe is it possible, to retrieve the
Request
inside the DynamicFormBuilder and check it automatically ?The text was updated successfully, but these errors were encountered: