diff --git a/src/Forms/FormField.php b/src/Forms/FormField.php index 00eef25510c..9f4ec88531a 100644 --- a/src/Forms/FormField.php +++ b/src/Forms/FormField.php @@ -443,14 +443,35 @@ public function getInputType() return $this->inputType; } + /** + * Returns the internal value of the field + * + * @return mixed + */ + public function getValue() + { + return $this->value; + } + + /** + * Returns the value of the field which may be modified for display purposes + * for instance to add localisation or formatting. + */ + public function getFormattedValue(): mixed + { + return $this->Value(); + } + /** * Returns the field value. * * @see FormField::setSubmittedValue() * @return mixed + * @deprecated 5.4.0 Use getFormattedValue() or getValue() instead */ public function Value() { + Deprecation::notice('5.4.0', 'Use getFormattedValue() or getValue() instead'); return $this->value; } diff --git a/src/Forms/TextareaField.php b/src/Forms/TextareaField.php index 0dd025a7f74..f6a55210cf6 100644 --- a/src/Forms/TextareaField.php +++ b/src/Forms/TextareaField.php @@ -2,6 +2,8 @@ namespace SilverStripe\Forms; +use SilverStripe\Dev\Deprecation; + /** * TextareaField creates a multi-line text field, * allowing more data to be entered than a standard @@ -202,13 +204,23 @@ public function getSchemaValidation() return $rules; } + /** + * Return value with all values encoded in html entities + */ + public function getFormattedValueEntities(): string + { + return htmlentities($this->Value() ?? '', ENT_COMPAT, 'UTF-8'); + } + /** * Return value with all values encoded in html entities * * @return string Raw HTML + * @deprecated 5.4.0 Use getFormattedValueEntities() instead */ public function ValueEntities() { - return htmlentities($this->Value() ?? '', ENT_COMPAT, 'UTF-8'); + Deprecation::noticeWithNoReplacment('5.4.0', 'Use getFormattedValueEntities() instead'); + return $this->getFormattedValueEntities(); } }