Added performDisabledTransformation() and performReadonlyTransformation() methods that set a TextareaField to be disabled (unselectable, not sent by browser when form is submitted) and readonly (selectable, sent by browser when form is submitted).

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@39927 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Matt Peel 2007-08-13 11:54:44 +00:00
parent 7780205ba9
commit 8a36ab4ed5
1 changed files with 30 additions and 3 deletions

View File

@ -3,7 +3,7 @@
* Multi-line text area.
*/
class TextareaField extends FormField {
protected $rows, $cols;
protected $rows, $cols, $disabled = false, $readonly = false;
/**
* Create a new multi-line text area field.
@ -30,7 +30,34 @@ class TextareaField extends FormField {
$classAttr = '';
}
return "<textarea $classAttr id=\"" . $this->id() . "\" name=\"{$this->name}\" rows=\"{$this->rows}\" cols=\"{$this->cols}\">".Convert::raw2att($this->value)."</textarea>";
}
$disabled = $this->disabled ? " disabled=\"disabled\"" : "";
$readonly = $this->readonly ? " readonly=\"readonly\"" : "";
return "<textarea $disabled$readonly $classAttr id=\"" . $this->id() . "\" name=\"{$this->name}\" rows=\"{$this->rows}\" cols=\"{$this->cols}\">".Convert::raw2att($this->value)."</textarea>";
}
/**
* Performs a readonly transformation on this field. You should still be able
* to copy from this field, and it should still send when you submit
* the form it's attached to.
* The element shouldn't be both disabled and readonly at the same time.
*/
function performReadonlyTransformation() {
$this->readonly = true;
$this->disabled = false;
return $this;
}
/**
* Performs a disabled transformation on this field. You shouldn't be able to
* copy from this field, and it should not send any data when you submit the
* form it's attached to.
* The element shouldn't be both disabled and readonly at the same time.
*/
function performDisabledTransformation() {
$this->disabled = true;
$this->readonly = false;
return $this;
}
}
?>