mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
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:
parent
7780205ba9
commit
8a36ab4ed5
@ -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;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user