Commit a125080f authored by Hristo Chonov's avatar Hristo Chonov Committed by GitHub
Browse files

Issue #3209728 by hchonov, Wim Leers: Refactor constraint message to match...

Issue #3209728 by hchonov, Wim Leers: Refactor constraint message to match core's required field message
parent 354db154
Loading
Loading
Loading
Loading
+1 −1
Changes for src/Plugin/Validation/Constraint/RequireOnPublish.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -17,6 +17,6 @@ use Symfony\Component\Validator\Constraint;
 */
class RequireOnPublish extends Constraint {

  public $message = 'Field "%field_label" is required when publishing.';
  public $message = '@field_label field is required when publishing.';

}
+2 −2
Changes for src/Plugin/Validation/Constraint/RequireOnPublishValidator.php: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -106,7 +106,7 @@ class RequireOnPublishValidator extends ConstraintValidator implements Container
      }

      if ($is_published) {
        $message = $this->t($constraint->message, ['%field_label' => $field_config->getLabel()]);
        $message = $this->t($constraint->message, ['@field_label' => $field_config->getLabel()]);
        $this->context->buildViolation($message)->atPath($field->getName())->addViolation();
      }
      else {
@@ -114,7 +114,7 @@ class RequireOnPublishValidator extends ConstraintValidator implements Container
          continue;
        }

        $message = $this->t('%label can not be empty on publication', ['%label' => $field_config->getLabel()]);
        $message = $this->t('@label field can not be empty on publication', ['@label' => $field_config->getLabel()]);
        $this->messenger->addWarning($message);
      }
    }