mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #2085 from mateusz/password-autocomplete
Add autocomplete=off switch for the password field.
This commit is contained in:
commit
dfdb274773
@ -6,6 +6,14 @@
|
|||||||
*/
|
*/
|
||||||
class PasswordField extends TextField {
|
class PasswordField extends TextField {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Controls the autocomplete attribute on the field.
|
||||||
|
*
|
||||||
|
* Setting it to false will set the attribute to "off", which will hint the browser
|
||||||
|
* to not cache the password and to not use any password managers.
|
||||||
|
*/
|
||||||
|
private static $autocomplete;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an input field, class="text" and type="text" with an optional
|
* Returns an input field, class="text" and type="text" with an optional
|
||||||
* maxlength
|
* maxlength
|
||||||
@ -21,10 +29,17 @@ class PasswordField extends TextField {
|
|||||||
|
|
||||||
|
|
||||||
public function getAttributes() {
|
public function getAttributes() {
|
||||||
return array_merge(
|
$attributes = array_merge(
|
||||||
parent::getAttributes(),
|
parent::getAttributes(),
|
||||||
array('type' => 'password')
|
array('type' => 'password')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$autocomplete = Config::inst()->get('PasswordField', 'autocomplete');
|
||||||
|
if (isset($autocomplete)) {
|
||||||
|
$attributes['autocomplete'] = $autocomplete ? 'on' : 'off';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $attributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user