From fe08447fc0e6a65d639e7660c44f4eb92c4e0c50 Mon Sep 17 00:00:00 2001 From: Christopher Pitt Date: Mon, 27 Apr 2015 14:10:42 +1200 Subject: [PATCH] Clean up PasswordField --- forms/PasswordField.php | 50 ++++++++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/forms/PasswordField.php b/forms/PasswordField.php index 21ac2e212..c230ee9bf 100644 --- a/forms/PasswordField.php +++ b/forms/PasswordField.php @@ -1,11 +1,12 @@ 3) { - Deprecation::notice('3.0', 'Use setMaxLength() instead of constructor arguments', - Deprecation::SCOPE_GLOBAL); + Deprecation::notice( + '3.0', 'Use setMaxLength() instead of constructor arguments', + Deprecation::SCOPE_GLOBAL + ); } parent::__construct($name, $title, $value); } - + /** + * {@inheritdoc} + */ public function getAttributes() { - $attributes = array_merge( - parent::getAttributes(), - array('type' => 'password') + $attributes = array( + 'type' => 'password', ); $autocomplete = Config::inst()->get('PasswordField', 'autocomplete'); - if (isset($autocomplete)) { - $attributes['autocomplete'] = $autocomplete ? 'on' : 'off'; + + if($autocomplete) { + $attributes['autocomplete'] = 'on'; + } else { + $attributes['autocomplete'] = 'off'; } - return $attributes; + return array_merge( + parent::getAttributes(), + $attributes + ); } /** - * Makes a pretty readonly field with some stars in it + * Creates a read-only version of the field. + * + * @return FormField */ public function performReadonlyTransformation() { $field = $this->castedCopy('ReadonlyField'); + $field->setValue('*****'); - + return $field; } + /** + * {@inheritdoc} + */ public function Type() { return 'text password'; } } -