From 12e2c9cda1acedef918b2bd2926fd7d386156d32 Mon Sep 17 00:00:00 2001 From: Normann Lou Date: Wed, 15 Apr 2009 03:30:04 +0000 Subject: [PATCH] FEATURE: make PasswordField and ConfirmedPasswordField able to either readonly or disabled. git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@74503 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- forms/ConfirmedPasswordField.php | 2 ++ forms/PasswordField.php | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/forms/ConfirmedPasswordField.php b/forms/ConfirmedPasswordField.php index 530e2a732..b933c11db 100644 --- a/forms/ConfirmedPasswordField.php +++ b/forms/ConfirmedPasswordField.php @@ -117,6 +117,8 @@ class ConfirmedPasswordField extends FormField { } foreach($this->children as $field) { + $field->setDisabled($this->isDisabled()); + $field->setReadonly($this->isReadonly()); $content .= $field->FieldHolder(); } diff --git a/forms/PasswordField.php b/forms/PasswordField.php index 2df9000a1..f5da3a5e9 100755 --- a/forms/PasswordField.php +++ b/forms/PasswordField.php @@ -26,12 +26,14 @@ class PasswordField extends FormField { function Field() { if($this->maxLength) { + $disabled = $this->isDisabled()?"disabled=\"disabled\"":""; + $readonly = $this->isReadonly()?"readonly=\"readonly\"":""; return "id() . "\" name=\"{$this->name}\" value=\"" . $this->attrValue() . - "\" maxlength=\"$this->maxLength\" size=\"$this->maxLength\"/>"; + "\" maxlength=\"$this->maxLength\" size=\"$this->maxLength\" $disabled $readonly />"; } else { return "id() . - "\" name=\"{$this->name}\" value=\"" . $this->attrValue() . "\" />"; + "\" name=\"{$this->name}\" value=\"" . $this->attrValue() . "\" $disabled $readonly />"; } }