-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Added example on how to adjust the validation message for specific form field #6937
Added example on how to adjust the validation message for specific form field #6937
Conversation
An admin must run tests on this PR before it can be merged. |
Also, it is possible to adjust existing error message for some specific form field separately. | ||
|
||
This is implemented in the core codebase in scope of the [`Magento_CatlogSearch` module]({{ site.mage2bloburl }}/{{page.guide_version}}/app/code/Magento/CatalogSearch/view/frontend/templates/advanced/form.phtml). | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @vasilii-b. Thank you for the great example. Could I ask you to add an extended explanation of what exactly needs to be done in order to adjust the message for a specific field?
The example below shows how it's done in the core but it does not explain the process explicitly. The question that may appear, do we need to modify the errorPlacement
for adjusting the message or it's enough to add the corresponding item into the messages
object?
Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @rogyar,
Thanks for looking into it.
Answering your question - no, the errorPlacement
does not affect the modification of the message.
The errorPlacement
adjusts where the validation message will show up when the validation rule not passed.
I'll update the file accordingly.
Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thank you!
13be9ea
to
6086890
Compare
Hi @rogyar, |
running tests |
Hi @vasilii-b, thank you for your contribution! |
@dobooth The hand of fate has been dealt. You must add a section for |
Purpose of this pull request
This pull request (PR) add example on how to change validation message for form fields separately using existing validation rules.
Affected DevDocs pages
Links to Magento source code
whatsnew
Added example for adjusting the form validation message in the Custom validation rules topic.