From 8a36ab4ed5797121449e4b22bddcd2b6140c4ac6 Mon Sep 17 00:00:00 2001 From: Matt Peel Date: Mon, 13 Aug 2007 11:54:44 +0000 Subject: [PATCH] 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 --- forms/TextareaField.php | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/forms/TextareaField.php b/forms/TextareaField.php index d7e12ea31..9ffd7c024 100755 --- a/forms/TextareaField.php +++ b/forms/TextareaField.php @@ -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 ""; - } + $disabled = $this->disabled ? " disabled=\"disabled\"" : ""; + $readonly = $this->readonly ? " readonly=\"readonly\"" : ""; + + return ""; + } + + /** + * 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; + } } ?>