Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Added example on how to adjust the validation message for specific form field #6937

Conversation

vasilii-b
Copy link

@vasilii-b vasilii-b commented Mar 27, 2020

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.

@devops-devdocs
Copy link
Collaborator

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).

Copy link
Contributor

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!

Copy link
Author

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!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thank you!

@rogyar rogyar added 2.3.x Magento 2.3 related changes Technical Updates to the code or processes that alter the technical content of the doc labels Mar 27, 2020
@vasilii-b vasilii-b force-pushed the custom-validation-message-based-on-form-input-name branch from 13be9ea to 6086890 Compare March 27, 2020 13:48
@vasilii-b
Copy link
Author

Hi @rogyar,
An extended explanation has been added.
Thank you!

@vasilii-b vasilii-b requested a review from rogyar March 27, 2020 13:55
@rogyar rogyar added Major Update Significant original updates to existing content and removed Technical Updates to the code or processes that alter the technical content of the doc labels Mar 30, 2020
@dobooth
Copy link
Contributor

dobooth commented Apr 1, 2020

running tests

@dobooth dobooth merged commit 4848683 into magento:master Apr 1, 2020
@ghost
Copy link

ghost commented Apr 1, 2020

Hi @vasilii-b, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

@hguthrie
Copy link
Contributor

@dobooth The hand of fate has been dealt. You must add a section for whatsnew or change your labeling strategy.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
2.3.x Magento 2.3 related changes Major Update Significant original updates to existing content Partner: Atwix partners-contribution PR created by Magento partner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants