From f734c2f0330a8f1280737ffb31a1e2c61e51342f Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Mon, 3 Sep 2018 13:37:21 +0200 Subject: [PATCH] FIX Do not override core translation for 'field is required' --- code/Model/EditableFormField.php | 5 +++-- lang/en.yml | 3 +-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/code/Model/EditableFormField.php b/code/Model/EditableFormField.php index 826b401..ddff655 100755 --- a/code/Model/EditableFormField.php +++ b/code/Model/EditableFormField.php @@ -27,6 +27,7 @@ use SilverStripe\ORM\ArrayList; use SilverStripe\ORM\DataObject; use SilverStripe\ORM\DB; use SilverStripe\ORM\FieldType\DBField; +use SilverStripe\ORM\FieldType\DBVarchar; use SilverStripe\ORM\ValidationException; use SilverStripe\UserForms\Extension\UserFormFieldEditorExtension; use SilverStripe\UserForms\Model\EditableFormField\EditableFieldGroup; @@ -801,12 +802,12 @@ class EditableFormField extends DataObject * Return the error message for this field. Either uses the custom * one (if provided) or the default SilverStripe message * - * @return Varchar + * @return DBVarchar */ public function getErrorMessage() { $title = strip_tags("'". ($this->Title ? $this->Title : $this->Name) . "'"); - $standard = _t('SilverStripe\\Forms\\Form.FIELDISREQUIRED', '{name} is required.', ['name' => $title]); + $standard = _t(__CLASS__ . '.FIELDISREQUIRED', '{name} is required', ['name' => $title]); // only use CustomErrorMessage if it has a non empty value $errorMessage = (!empty($this->CustomErrorMessage)) ? $this->CustomErrorMessage : $standard; diff --git a/lang/en.yml b/lang/en.yml index 3826e03..6f5f1df 100644 --- a/lang/en.yml +++ b/lang/en.yml @@ -3,8 +3,6 @@ en: SELECTUPLOADFOLDER: 'Select upload folder' SilverStripe\CMS\Model\SiteTree: TABMAIN: Main - SilverStripe\Forms\Form: - FIELDISREQUIRED: '{name} is required.' SilverStripe\UserForms: ADDEMAILRECIPIENT: 'Add Email Recipient' CLEARBUTTON: Clear @@ -57,6 +55,7 @@ en: EXTRACLASS_SELECT: 'Select from the list of allowed styles' EXTRACLASS_TITLE: 'Extra Styling/Layout' EXTRACLASS_Title: 'Extra CSS classes' + FIELDISREQUIRED: '{name} is required' GROUP: Group INITIALVISIBILITY: 'Initial visibility' MERGEFIELDNAME: 'Merge field'