includeHiddenField = $includeHiddenField; } public function performReadonlyTransformation() { return clone $this; } /** * @param array $properties * @return HTMLText */ public function Field($properties = array()) { // Include a hidden field in the HTML if($this->includeHiddenField && $this->readonly) { $hidden = clone $this; $hidden->setReadonly(false); return parent::Field($properties) . $hidden->Field($properties); } else { return parent::Field($properties); } } public function Value() { if($this->value) return $this->value; else return '(' . _t('FormField.NONE', 'none') . ')'; } /** * This is a legacy fix to ensure that the `dontEscape` flag has an impact on readonly fields * now that we've moved to casting template values more rigidly * * @param string $field * @return string */ public function castingHelper($field) { if ( (strcasecmp($field, 'Value') === 0) && ($this->dontEscape || empty($this->value)) ) { // Value is either empty, or unescaped return 'HTMLText'; } return parent::castingHelper($field); } public function getAttributes() { return array_merge( parent::getAttributes(), array( 'type' => 'hidden', 'value' => $this->readonly ? null : $this->value, ) ); } public function Type() { return 'readonly'; } }