JavaScript validation is enabled by default for all forms.
The js_validation option can be set at three levels:
Disable validation for all forms:
# config/packages/svaroh_js_form_validator.yaml
svaroh_js_form_validator:
js_validation: falseOverride the global setting for a specific form type:
<?php
namespace App\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\OptionsResolver\OptionsResolver;
class UserType extends AbstractType
{
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'js_validation' => false, // Disable for this form only
]);
}
}When the form option is not explicitly set (i.e., it is null), the form
inherits the global configuration value. This allows you to:
- Disable validation globally (
js_validation: false) and then enable it only for selected forms by setting'js_validation' => trueon those forms. - Enable validation globally (the default) and disable it for specific forms
by setting
'js_validation' => falseon those forms.