File tree 1 file changed +14
-2
lines changed
1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -15,18 +15,26 @@ class PasswordElement extends InputElement
15
15
/** @var bool Status of the form */
16
16
protected $ isFormValid = true ;
17
17
18
+ /** @var bool Status indicating if the form got submitted */
19
+ protected $ isFormSubmitted = false ;
20
+
18
21
protected function registerAttributeCallbacks (Attributes $ attributes )
19
22
{
20
23
parent ::registerAttributeCallbacks ($ attributes );
21
24
22
25
$ attributes ->registerAttributeCallback (
23
26
'value ' ,
24
27
function () {
25
- if ($ this ->hasValue () && count ($ this ->getValueCandidates ()) === 1 && $ this ->isFormValid ) {
28
+ if (
29
+ $ this ->hasValue ()
30
+ && count ($ this ->getValueCandidates ()) === 1
31
+ && $ this ->isFormValid
32
+ && ! $ this ->isFormSubmitted
33
+ ) {
26
34
return self ::DUMMYPASSWORD ;
27
35
}
28
36
29
- if (parent ::getValue () === self ::DUMMYPASSWORD ) {
37
+ if (parent ::getValue () === self ::DUMMYPASSWORD && count ( $ this -> getValueCandidates ()) > 1 ) {
30
38
return self ::DUMMYPASSWORD ;
31
39
}
32
40
@@ -40,6 +48,10 @@ public function onRegistered(Form $form)
40
48
$ form ->on (Form::ON_VALIDATE , function ($ form ) {
41
49
$ this ->isFormValid = $ form ->isValid ();
42
50
});
51
+
52
+ $ form ->on (Form::ON_SENT , function ($ form ) {
53
+ $ this ->isFormSubmitted = $ form ->hasBeenSent ();
54
+ });
43
55
}
44
56
45
57
public function getValue ()
You can’t perform that action at this time.
0 commit comments