9
9
* file that was distributed with this source code.
10
10
*/
11
11
12
- namespace App \Form \ Type ;
12
+ namespace App \Form ;
13
13
14
+ use App \Entity \User ;
14
15
use Symfony \Component \Form \AbstractType ;
15
16
use Symfony \Component \Form \Extension \Core \Type \PasswordType ;
16
17
use Symfony \Component \Form \Extension \Core \Type \RepeatedType ;
17
18
use Symfony \Component \Form \FormBuilderInterface ;
19
+ use Symfony \Component \OptionsResolver \OptionsResolver ;
18
20
use Symfony \Component \Security \Core \Validator \Constraints \UserPassword ;
19
21
use Symfony \Component \Validator \Constraints \Length ;
20
22
use Symfony \Component \Validator \Constraints \NotBlank ;
21
23
22
24
/**
23
- * Defines the custom form field type used to change user's password.
25
+ * Defines the form used to change user's password.
24
26
*
25
27
* @author Romain Monteil <monteil.romain@gmail.com>
26
28
*/
@@ -37,6 +39,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
37
39
new UserPassword (),
38
40
],
39
41
'label ' => 'label.current_password ' ,
42
+ 'mapped ' => false ,
40
43
'attr ' => [
41
44
'autocomplete ' => 'off ' ,
42
45
],
@@ -51,12 +54,24 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
51
54
),
52
55
],
53
56
'first_options ' => [
57
+ 'hash_property_path ' => 'password ' ,
54
58
'label ' => 'label.new_password ' ,
55
59
],
60
+ 'mapped ' => false ,
56
61
'second_options ' => [
57
62
'label ' => 'label.new_password_confirm ' ,
58
63
],
59
64
])
60
65
;
61
66
}
67
+
68
+ /**
69
+ * {@inheritdoc}
70
+ */
71
+ public function configureOptions (OptionsResolver $ resolver ): void
72
+ {
73
+ $ resolver ->setDefaults ([
74
+ 'data_class ' => User::class,
75
+ ]);
76
+ }
62
77
}
0 commit comments