includeHiddenField = $includeHiddenField; return $this; } /** * @return bool */ public function getIncludeHiddenField() { return $this->includeHiddenField; } public function performReadonlyTransformation() { return clone $this; } public function Type() { return 'readonly'; } public function castingHelper($field) { // Get dynamic cast for 'Value' field if (strcasecmp($field ?? '', 'Value') === 0) { return $this->getValueCast(); } // Fall back to default casting return parent::castingHelper($field); } public function getSchemaStateDefaults() { $state = parent::getSchemaStateDefaults(); $state['value'] = $this->dataValue(); return $state; } /** * @return mixed|string */ public function Value() { // Get raw value $value = $this->dataValue(); if ($value) { return $value; } // "none" text $label = _t('SilverStripe\\Forms\\FormField.NONE', 'none'); return "('{$label}')"; } /** * Get custom cating helper for Value() field * * @return string */ public function getValueCast() { // Casting class for 'none' text $value = $this->dataValue(); if (empty($value)) { return 'HTMLFragment'; } // Use default casting $casting = $this->config()->get('casting'); return $casting['Value']; } }