Currently, all error messages are hardcoded in the module - $form_state->setErrorByName($field_name, t('The field @field_label has to be unique.', ['@field_label' => $field_label]));
It should be possible to customize warnings.
Solution:
1. Create a new permission to access the config page.
2. Create a new /admin/config/content/unique-fields route.
3. Create a form with three text fields (node/term/user) to add warning messages.
all fields should be optional and should provide a description about the @label placeholder.
all field values should be saved to the unique_field.settings config under the warnings key
4. Update validation callbacks to show custom messages.
notes:
- we should show an old message if the config is empty;
- we should support @label placeholder;
- it should be possible to translate warnings
Issue fork unique_field-3570354
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
astonvictor commentedComment #3
astonvictor commentedComment #4
lysenkoComment #7
astonvictor commented