2007-07-19 12:40:28 +02:00
|
|
|
<?php
|
|
|
|
/**
|
2007-09-15 23:38:05 +02:00
|
|
|
* Password input field.
|
2008-01-09 05:18:36 +01:00
|
|
|
* @package forms
|
|
|
|
* @subpackage fields-formattedinput
|
2007-07-19 12:40:28 +02:00
|
|
|
*/
|
2011-12-21 17:35:42 +01:00
|
|
|
class PasswordField extends TextField {
|
2007-09-15 23:38:05 +02:00
|
|
|
|
2007-07-19 12:40:28 +02:00
|
|
|
/**
|
2007-09-15 23:38:05 +02:00
|
|
|
* Returns an input field, class="text" and type="text" with an optional
|
|
|
|
* maxlength
|
2007-07-19 12:40:28 +02:00
|
|
|
*/
|
2012-09-19 12:07:39 +02:00
|
|
|
public function __construct($name, $title = null, $value = "") {
|
2012-09-26 23:34:00 +02:00
|
|
|
if(count(func_get_args()) > 3) {
|
|
|
|
Deprecation::notice('3.0', 'Use setMaxLength() instead of constructor arguments',
|
|
|
|
Deprecation::SCOPE_GLOBAL);
|
|
|
|
}
|
2012-01-02 17:45:47 +01:00
|
|
|
|
2007-09-15 23:38:05 +02:00
|
|
|
parent::__construct($name, $title, $value);
|
2007-07-19 12:40:28 +02:00
|
|
|
}
|
2007-09-15 23:38:05 +02:00
|
|
|
|
|
|
|
|
2012-09-19 12:07:39 +02:00
|
|
|
public function getAttributes() {
|
2011-12-22 13:10:57 +01:00
|
|
|
return array_merge(
|
|
|
|
parent::getAttributes(),
|
|
|
|
array('type' => 'password')
|
|
|
|
);
|
2007-07-19 12:40:28 +02:00
|
|
|
}
|
2007-09-15 23:38:05 +02:00
|
|
|
|
2007-07-19 12:40:28 +02:00
|
|
|
/**
|
2007-09-15 23:38:05 +02:00
|
|
|
* Makes a pretty readonly field with some stars in it
|
2007-07-19 12:40:28 +02:00
|
|
|
*/
|
2012-09-19 12:07:39 +02:00
|
|
|
public function performReadonlyTransformation() {
|
2007-09-15 23:38:05 +02:00
|
|
|
$stars = '*****';
|
|
|
|
|
|
|
|
$field = new ReadonlyField($this->name, $this->title ? $this->title : '', $stars);
|
2007-07-19 12:40:28 +02:00
|
|
|
$field->setForm($this->form);
|
2008-08-12 04:58:48 +02:00
|
|
|
$field->setReadonly(true);
|
2007-07-19 12:40:28 +02:00
|
|
|
return $field;
|
|
|
|
}
|
2011-12-22 13:10:57 +01:00
|
|
|
|
2012-09-19 12:07:39 +02:00
|
|
|
public function Type() {
|
2011-12-22 13:10:57 +01:00
|
|
|
return 'text password';
|
|
|
|
}
|
2007-07-19 12:40:28 +02:00
|
|
|
}
|
2007-09-15 23:38:05 +02:00
|
|
|
|