diff --git a/src/FormElement/PasswordElement.php b/src/FormElement/PasswordElement.php new file mode 100644 index 00000000..6010c154 --- /dev/null +++ b/src/FormElement/PasswordElement.php @@ -0,0 +1,35 @@ +password; + } + + public function setValue($value) + { + parent::setValue($value); + // Consider any changes to the password made by the parent setValue() call. + $value = parent::getValue(); + + if ($value !== static::OBSCURE_PASSWORD) { + $this->password = $value; + } + + return $this; + } + + public function getValueAttribute() + { + return $this->hasValue() ? static::OBSCURE_PASSWORD : null; + } +} diff --git a/tests/TestDummy/ObscurePassword.php b/tests/TestDummy/ObscurePassword.php index fa6e0185..80012c73 100644 --- a/tests/TestDummy/ObscurePassword.php +++ b/tests/TestDummy/ObscurePassword.php @@ -8,6 +8,6 @@ class ObscurePassword extends PasswordElement { public static function get(): string { - return static::DUMMYPASSWORD; + return static::OBSCURE_PASSWORD; } }