This is the link to my form window
Can anybody suggest how to customize the error messages in my form window like - 'This value is not valid', 'Passwords do not match' to appear like a pop up error message for empty field?
This is the link to my form window
Can anybody suggest how to customize the error messages in my form window like - 'This value is not valid', 'Passwords do not match' to appear like a pop up error message for empty field?
Validation error messages can be customized at your bundles validation.yml
file. I have added an example.
# src/Vendor/YourBundleName/Resources/config/validation.yml
Vendor\YourBundleName\Entity\YourModel:
properties:
email:
- Email:
message: The email you entered is not a valid email.
- NotBlank
message: Please enter email.
Please read validation doc section and validation constraint reference carefully.
It's not symfony but the browser's implementation of the "required" attribute which display these ugly alert messages. Looks like we can't customize this attribute with html/css only but you can try to play around with jquery to customize the error messages before htm5 catch the user input.
Someone asked something similar, hope it can help you: override css for html5 form validation/required popup
I think you search for invalid_message. you can customize your message just like following code block:
$inputsForm = $this->createFormBuilder()
->add("networkAddress", TextType::class,[
'required'=>true
])
->add("hostsCount",NumberType::class, [
'required'=>true,
'invalid_message'=>'my error message!'
])
->add('calc',SubmitType::class,['label'=>'Berechnen'])
->getForm();
I think you mean form theme customization, you can check out the official doc:
http://symfony.com/doc/current/cookbook/form/form_customization.html