Problem/Motivation

The core's validation message for required fields is:
'@name field is required.'
while the message provided by the module's constraint is:
'Field "%field_label" is required when publishing.'

Proposed resolution

I think it would be better to refactor the message to be more similar to the core's one:
'@field_label field is required when publishing.'

Comments

hchonov created an issue. See original summary.

hchonov’s picture

StatusFileSize
new898 bytes
hchonov’s picture

StatusFileSize
new538 bytes

oups, uploaded the wrong patch with my previous comment :)

hchonov’s picture

StatusFileSize
new1.69 KB

One more place had to be updated.

hchonov’s picture

StatusFileSize
new1.69 KB
wim leers’s picture

Status: Needs review » Reviewed & tested by the community
+++ b/src/Plugin/Validation/Constraint/RequireOnPublish.php
@@ -17,6 +17,6 @@ use Symfony\Component\Validator\Constraint;
-  public $message = 'Field "%field_label" is required when publishing.';
+  public $message = '@field_label field is required when publishing.';
 

Can confirm this matches

$form_state->setError($elements, $this->t('@name field is required.', ['@name' => $elements['#title']]));

in FormValidator.

  • hchonov authored a125080 on 8.x-1.x
    Issue #3209728 by hchonov, Wim Leers: Refactor constraint message to...
markdorison’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.