Skip to content

Commit

Permalink
API Deprecate FormField Value
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Jan 29, 2025
1 parent 0aa00a6 commit 7e88a6d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/Forms/FormField.php
Original file line number Diff line number Diff line change
Expand Up @@ -448,9 +448,11 @@ public function getInputType()
*
* @see FormField::setSubmittedValue()
* @return mixed
* @deprecated 5.4.0 Will be replaced by getFormattedValue() and getValue()
*/
public function Value()
{
Deprecation::notice('5.4.0', 'Will be replaced by getFormattedValue() and getValue()');
return $this->value;
}

Expand Down
14 changes: 13 additions & 1 deletion src/Forms/TextareaField.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
}
}

0 comments on commit 7e88a6d

Please sign in to comment.