diff --git a/src/Forms/CheckboxField.php b/src/Forms/CheckboxField.php index 48f1c652e87..90a742e8feb 100644 --- a/src/Forms/CheckboxField.php +++ b/src/Forms/CheckboxField.php @@ -21,7 +21,7 @@ public function dataValue() return ($this->value) ? 1 : null; } - public function Value() + public function getValue(): mixed { return ($this->value) ? 1 : 0; } @@ -39,7 +39,7 @@ public function getAttributes() return array_merge( $attributes, [ - 'checked' => ($this->Value()) ? 'checked' : null, + 'checked' => ($this->getValue()) ? 'checked' : null, 'type' => 'checkbox', ] ); diff --git a/src/Forms/CheckboxField_Readonly.php b/src/Forms/CheckboxField_Readonly.php index f161a66c746..497a6bf1e30 100644 --- a/src/Forms/CheckboxField_Readonly.php +++ b/src/Forms/CheckboxField_Readonly.php @@ -13,7 +13,7 @@ public function performReadonlyTransformation() return clone $this; } - public function Value() + public function getFormattedValue(): string { return $this->value ? _t('SilverStripe\\Forms\\CheckboxField.YESANSWER', 'Yes') : diff --git a/src/Forms/ConfirmedPasswordField.php b/src/Forms/ConfirmedPasswordField.php index 34a084be5a8..e9e594240ef 100644 --- a/src/Forms/ConfirmedPasswordField.php +++ b/src/Forms/ConfirmedPasswordField.php @@ -204,7 +204,7 @@ public function Field($properties = []) } // Check if the field should be visible up front - $visible = $this->hiddenField->Value(); + $visible = $this->hiddenField->getValue(); $classes = $visible ? 'showOnClickContainer' : 'showOnClickContainer d-none'; @@ -418,7 +418,7 @@ public function setName($name) public function isSaveable() { return !$this->showOnClick - || ($this->showOnClick && $this->hiddenField && $this->hiddenField->Value()); + || ($this->showOnClick && $this->hiddenField && $this->hiddenField->getValue()); } public function validate(): ValidationResult @@ -432,10 +432,10 @@ public function validate(): ValidationResult $this->getPasswordField()->setValue($this->value); $this->getConfirmPasswordField()->setValue($this->confirmValue); - $value = $this->getPasswordField()->Value(); + $value = $this->getPasswordField()->getValue(); // both password-fields should be the same - if ($value != $this->getConfirmPasswordField()->Value()) { + if ($value != $this->getConfirmPasswordField()->getValue()) { $result->addFieldError( $name, _t('SilverStripe\\Forms\\Form.VALIDATIONPASSWORDSDONTMATCH', "Passwords don't match"), @@ -446,7 +446,7 @@ public function validate(): ValidationResult if (!$this->canBeEmpty) { // both password-fields shouldn't be empty - if (!$value || !$this->getConfirmPasswordField()->Value()) { + if (!$value || !$this->getConfirmPasswordField()->getValue()) { $result->addFieldError( $name, _t('SilverStripe\\Forms\\Form.VALIDATIONPASSWORDSNOTEMPTY', "Passwords can't be empty"), diff --git a/src/Forms/DateField.php b/src/Forms/DateField.php index 914b20f72ea..892a4d71c7c 100644 --- a/src/Forms/DateField.php +++ b/src/Forms/DateField.php @@ -343,7 +343,7 @@ public function setValue($value, $data = null) return $this; } - public function Value() + public function getFormattedValue(): string { return $this->internalToFrontend($this->value); } diff --git a/src/Forms/DateField_Disabled.php b/src/Forms/DateField_Disabled.php index be56d92ea5a..bb68af5fd48 100644 --- a/src/Forms/DateField_Disabled.php +++ b/src/Forms/DateField_Disabled.php @@ -39,7 +39,7 @@ public function Field($properties = []) // Render the display value with some complement of info $displayValue = Convert::raw2xml(sprintf( $format ?? '', - $this->Value(), + $this->getFormattedValue(), $infoComplement )); } diff --git a/src/Forms/DatetimeField.php b/src/Forms/DatetimeField.php index cfa1beb012c..0c414ee978e 100644 --- a/src/Forms/DatetimeField.php +++ b/src/Forms/DatetimeField.php @@ -362,7 +362,7 @@ public function setValue($value, $data = null) * * @return string */ - public function Value() + public function getFormattedValue(): string { return $this->internalToFrontend($this->value); } diff --git a/src/Forms/DropdownField.php b/src/Forms/DropdownField.php index 9e31245250f..e0e1ef6067b 100644 --- a/src/Forms/DropdownField.php +++ b/src/Forms/DropdownField.php @@ -97,7 +97,7 @@ class DropdownField extends SingleSelectField protected function getFieldOption($value, $title) { // Check selection - $selected = $this->isSelectedValue($value, $this->Value()); + $selected = $this->isSelectedValue($value, $this->getValue()); // Check disabled $disabled = false; diff --git a/src/Forms/FileField.php b/src/Forms/FileField.php index fdeed0a59d7..6760ab03de0 100644 --- a/src/Forms/FileField.php +++ b/src/Forms/FileField.php @@ -172,7 +172,7 @@ public function saveInto(DataObjectInterface $record) } } - public function Value() + public function getValue(): mixed { return isset($_FILES[$this->getName()]) ? $_FILES[$this->getName()] : null; } diff --git a/src/Forms/FileUploadReceiver.php b/src/Forms/FileUploadReceiver.php index 3aaa42ff323..4c9752f3b27 100644 --- a/src/Forms/FileUploadReceiver.php +++ b/src/Forms/FileUploadReceiver.php @@ -237,11 +237,11 @@ public function getItems() */ public function getItemIDs() { - $value = $this->Value(); + $value = $this->getValue(); return empty($value['Files']) ? [] : $value['Files']; } - public function Value() + public function getValue() { // Re-override FileField Value to use data value return $this->dataValue(); diff --git a/src/Forms/FormField.php b/src/Forms/FormField.php index 3ec6d06eb7a..bc8a50581c7 100644 --- a/src/Forms/FormField.php +++ b/src/Forms/FormField.php @@ -457,10 +457,8 @@ public function getValue(): mixed /** * Returns the value of the field which may be modified for display purposes * for instance to add localisation or formatting. - * - * @return mixed */ - public function Value() + public function getFormattedValue(): string { return $this->value; } @@ -668,7 +666,7 @@ protected function getDefaultAttributes(): array $attributes = [ 'type' => $this->getInputType(), 'name' => $this->getName(), - 'value' => $this->Value(), + 'value' => $this->getFormattedValue(), 'class' => $this->extraClass(), 'id' => $this->ID(), 'disabled' => $this->isDisabled(), @@ -1554,7 +1552,7 @@ public function getSchemaStateDefaults() $state = [ 'name' => $this->getName(), 'id' => $this->ID(), - 'value' => $this->Value(), + 'value' => $this->getFormattedValue(), 'message' => $this->getSchemaMessage(), 'data' => [], ]; diff --git a/src/Forms/GridField/GridField.php b/src/Forms/GridField/GridField.php index 05c204b6dbb..ef7e94d7262 100644 --- a/src/Forms/GridField/GridField.php +++ b/src/Forms/GridField/GridField.php @@ -485,7 +485,7 @@ private function addStateFromRequest(): void // Create a dummy state so that we can merge the current state with the request state. $newState = new GridState($this, $stateStr); // Put the current state on top of the request state. - $newState->setValue($oldState->Value()); + $newState->setValue($oldState->getValue()); $this->state = $newState; } } diff --git a/src/Forms/GridField/GridFieldStateManager.php b/src/Forms/GridField/GridFieldStateManager.php index 727077737a3..53ac56b3e05 100644 --- a/src/Forms/GridField/GridFieldStateManager.php +++ b/src/Forms/GridField/GridFieldStateManager.php @@ -39,7 +39,7 @@ public function getStateKey(GridField $gridField): string public function addStateToURL(GridField $gridField, string $url): string { $key = $this->getStateKey($gridField); - $value = $gridField->getState(false)->Value(); + $value = $gridField->getState(false)->getValue(); // Using a JSON-encoded empty array as the blank value, to avoid changing Value() semantics in a minor release if ($value === '{}') { diff --git a/src/Forms/GridField/GridState.php b/src/Forms/GridField/GridState.php index a5f5725970a..7e97f9f878e 100644 --- a/src/Forms/GridField/GridState.php +++ b/src/Forms/GridField/GridState.php @@ -101,10 +101,8 @@ public function getList() /** * Returns a json encoded string representation of this state. - * - * @return string */ - public function Value() + public function getValue(): string { $data = $this->data ? $this->data->getChangesArray() : []; return json_encode($data, JSON_FORCE_OBJECT); @@ -117,7 +115,7 @@ public function Value() */ public function dataValue() { - return $this->Value(); + return $this->getValue(); } /** @@ -126,11 +124,11 @@ public function dataValue() */ public function attrValue() { - return Convert::raw2att($this->Value()); + return Convert::raw2att($this->getValue()); } public function __toString() { - return $this->Value(); + return $this->getValue(); } } diff --git a/src/Forms/HTMLEditor/HTMLEditorField.php b/src/Forms/HTMLEditor/HTMLEditorField.php index 4527dd1de6a..8aa3e8a2b02 100644 --- a/src/Forms/HTMLEditor/HTMLEditorField.php +++ b/src/Forms/HTMLEditor/HTMLEditorField.php @@ -134,7 +134,7 @@ public function saveInto(DataObjectInterface $record) } // Sanitise if requested - $htmlValue = HTMLValue::create($this->Value()); + $htmlValue = HTMLValue::create($this->getValue()); if (HTMLEditorField::config()->sanitise_server_side) { $config = $this->getEditorConfig(); $santiser = HTMLEditorSanitiser::create($config); @@ -200,7 +200,7 @@ public function ValueEntities() // Don't apply double encoding to ampersand $doubleEncoding = $matches[0] != '&'; return htmlentities($matches[0], ENT_COMPAT, 'UTF-8', $doubleEncoding); - }, $this->Value() ?? ''); + }, $this->getValue() ?? ''); return $value; } @@ -231,7 +231,7 @@ private function usesXmlFriendlyField(DataObjectInterface $record): bool } $castingService = CastingService::singleton(); - $castValue = $castingService->cast($this->Value(), $record, $this->getName()); + $castValue = $castingService->cast($this->getValue(), $record, $this->getName()); return $castValue instanceof DBField && $castValue::config()->get('escape_type') === 'xml'; } } diff --git a/src/Forms/HTMLReadonlyField.php b/src/Forms/HTMLReadonlyField.php index 64bb339e30f..d10fe598b50 100644 --- a/src/Forms/HTMLReadonlyField.php +++ b/src/Forms/HTMLReadonlyField.php @@ -33,6 +33,6 @@ public function Field($properties = []) */ public function ValueEntities() { - return htmlentities($this->Value() ?? '', ENT_COMPAT, 'UTF-8'); + return htmlentities($this->getFormattedValue() ?? '', ENT_COMPAT, 'UTF-8'); } } diff --git a/src/Forms/ListboxField.php b/src/Forms/ListboxField.php index 0a2112cae08..d4037a59b27 100644 --- a/src/Forms/ListboxField.php +++ b/src/Forms/ListboxField.php @@ -252,7 +252,7 @@ protected function getOptionsArray($term) public function getValueArray() { - $value = $this->Value(); + $value = $this->getValue(); $validValues = $this->getValidValues(); if (empty($validValues)) { return []; diff --git a/src/Forms/MoneyField.php b/src/Forms/MoneyField.php index 75e70d61f6a..74238558044 100644 --- a/src/Forms/MoneyField.php +++ b/src/Forms/MoneyField.php @@ -219,7 +219,7 @@ public function dataValue() return $this->getDBMoney()->getValue(); } - public function Value() + public function getFormattedValue(): string { // Localised money return $this->getDBMoney()->Nice(); diff --git a/src/Forms/MultiSelectField.php b/src/Forms/MultiSelectField.php index e3adb61c32e..5186a455f04 100644 --- a/src/Forms/MultiSelectField.php +++ b/src/Forms/MultiSelectField.php @@ -39,7 +39,7 @@ abstract class MultiSelectField extends SelectField */ public function getValueArray() { - return $this->getListValues($this->Value()); + return $this->getListValues($this->getValue()); } /** diff --git a/src/Forms/NullableField.php b/src/Forms/NullableField.php index 99669cd0ab8..954a8a45365 100644 --- a/src/Forms/NullableField.php +++ b/src/Forms/NullableField.php @@ -17,7 +17,7 @@ * When a form is submitted the field tests the value of the "is null" checkbox and sets its value * accordingly. You can retrieve the value of the wrapped field from the NullableField as follows: * - * $field->Value() or $field->dataValue() + * $field->getValue() or $field->dataValue() * * You can specify the label to use for the "is null" checkbox. If you want to use i18n for this * label then specify it like this: @@ -61,7 +61,7 @@ public function __construct(FormField $valueField, $isNullLabel = null) parent::__construct( $valueField->getName(), $valueField->Title(), - $valueField->Value() + $valueField->getValue() ); $this->setForm($valueField->getForm()); diff --git a/src/Forms/NumericField.php b/src/Forms/NumericField.php index cc36e9509dc..268e2989f13 100644 --- a/src/Forms/NumericField.php +++ b/src/Forms/NumericField.php @@ -169,7 +169,7 @@ public function setSubmittedValue($value, $data = null) * * @return string */ - public function Value() + public function getFormattedValue(): string { // Show invalid value back to user in case of error if ($this->value === null || $this->value === false) { diff --git a/src/Forms/OptionsetField.php b/src/Forms/OptionsetField.php index a966aebe375..53eddd68262 100644 --- a/src/Forms/OptionsetField.php +++ b/src/Forms/OptionsetField.php @@ -75,7 +75,7 @@ protected function getFieldOption($value, $title, $odd) 'Name' => $this->getOptionName(), 'Value' => $value, 'Title' => $title, - 'isChecked' => $this->isSelectedValue($value, $this->Value()), + 'isChecked' => $this->isSelectedValue($value, $this->getValue()), 'isDisabled' => $this->isDisabledValue($value) ]); } diff --git a/src/Forms/ReadonlyField.php b/src/Forms/ReadonlyField.php index 68a496a5d61..5c8e6428244 100644 --- a/src/Forms/ReadonlyField.php +++ b/src/Forms/ReadonlyField.php @@ -79,7 +79,7 @@ public function getSchemaStateDefaults() /** * @return mixed|string */ - public function Value() + public function getFormattedValue(): string { // Get raw value $value = $this->dataValue(); diff --git a/src/Forms/SearchableDropdownTrait.php b/src/Forms/SearchableDropdownTrait.php index a01697aabf2..764359e268f 100644 --- a/src/Forms/SearchableDropdownTrait.php +++ b/src/Forms/SearchableDropdownTrait.php @@ -320,7 +320,7 @@ public function getAttributes(): array */ public function getValueArray(): array { - $value = $this->Value(); + $value = $this->getValue(); if (empty($value)) { return []; } @@ -475,7 +475,7 @@ private function getDefaultSchemaValue() if (!$this->getIsLazyLoaded() && $this->hasMethod('getDefaultValue')) { return $this->getDefaultValue(); } - return $this->Value(); + return $this->getValue(); } private function getOptionsForSearchRequest(string $term): array diff --git a/src/Forms/SingleLookupField.php b/src/Forms/SingleLookupField.php index 1bf54b8f24e..4ba8b6f21c3 100644 --- a/src/Forms/SingleLookupField.php +++ b/src/Forms/SingleLookupField.php @@ -83,7 +83,7 @@ public function Type() * * @return mixed */ - public function Value() + public function getFormattedValue(): string { $label = $this->valueToLabel(); if (!is_null($label)) { diff --git a/src/Forms/SingleSelectField.php b/src/Forms/SingleSelectField.php index b2488c369cf..f8a0126cd78 100644 --- a/src/Forms/SingleSelectField.php +++ b/src/Forms/SingleSelectField.php @@ -58,7 +58,7 @@ public function getValueForValidation(): mixed public function getDefaultValue() { - $value = $this->Value(); + $value = $this->getValue(); $validValues = $this->getValidValues(); // assign value to field, such as first option available if ($value === null || !in_array($value, $validValues)) { diff --git a/src/Forms/TextareaField.php b/src/Forms/TextareaField.php index 6f764dcb2e4..b120133f401 100644 --- a/src/Forms/TextareaField.php +++ b/src/Forms/TextareaField.php @@ -192,6 +192,6 @@ public function getSchemaValidation() */ public function ValueEntities() { - return htmlentities($this->Value() ?? '', ENT_COMPAT, 'UTF-8'); + return htmlentities($this->getFormattedValue() ?? '', ENT_COMPAT, 'UTF-8'); } } diff --git a/src/Forms/TimeField.php b/src/Forms/TimeField.php index 082e11aee8e..727f8205f1f 100644 --- a/src/Forms/TimeField.php +++ b/src/Forms/TimeField.php @@ -280,7 +280,7 @@ public function setValue($value, $data = null) return $this; } - public function Value() + public function getFormattedValue(): string { $localised = $this->internalToFrontend($this->value); if ($localised) { diff --git a/src/Forms/TreeDropdownField.php b/src/Forms/TreeDropdownField.php index 7a8889dafca..69d5c994ba7 100644 --- a/src/Forms/TreeDropdownField.php +++ b/src/Forms/TreeDropdownField.php @@ -865,7 +865,7 @@ public function getSchemaStateDefaults() { $data = parent::getSchemaStateDefaults(); /** @var Hierarchy|DataObject $record */ - $record = $this->Value() ? $this->objectForKey($this->Value()) : null; + $record = $this->getValue() ? $this->objectForKey($this->getValue()) : null; $data['data']['cacheKey'] = $this->getCacheKey(); $data['data']['showSelectedPath'] = $this->getShowSelectedPath(); diff --git a/src/Forms/TreeMultiselectField.php b/src/Forms/TreeMultiselectField.php index 449a275fe45..48e8c8b9aad 100644 --- a/src/Forms/TreeMultiselectField.php +++ b/src/Forms/TreeMultiselectField.php @@ -121,7 +121,7 @@ public function getSchemaStateDefaults() */ public function getItems() { - $value = $this->Value(); + $value = $this->getValue(); // If unchanged, load from record if ($value === 'unchanged') { diff --git a/templates/SilverStripe/Forms/CheckboxSetField.ss b/templates/SilverStripe/Forms/CheckboxSetField.ss index 75d1a62b975..fc1d2f5b928 100644 --- a/templates/SilverStripe/Forms/CheckboxSetField.ss +++ b/templates/SilverStripe/Forms/CheckboxSetField.ss @@ -2,7 +2,7 @@ <% if $Options.Count %> <% loop $Options %>