File tree Expand file tree Collapse file tree 4 files changed +74
-0
lines changed Expand file tree Collapse file tree 4 files changed +74
-0
lines changed Original file line number Diff line number Diff line change @@ -207,3 +207,19 @@ Feature: It is possible to interactively fill in a form from the CLI
207207 [price] => 10.95
208208 )
209209 """
210+
211+ Scenario : Secret required field
212+ When I run the command "form:secret_required_field" and I provide as input
213+ """
214+ Jelmer[enter]
215+ """
216+ Then the command was not successful
217+ And the output should contain
218+ """
219+ Invalid data provided: ERROR: This value should not be blank.
220+ """
221+ And the output should contain
222+ """
223+ [RuntimeException]
224+ Errors out of the form's scope - do you have validation constraints on properties not used in the form?
225+ """
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Matthias \SymfonyConsoleForm \Tests \Form \Data ;
4+
5+ use Symfony \Component \Validator \Constraints as Assert ;
6+
7+ class SecretRequiredField
8+ {
9+ /**
10+ * @Assert\NotBlank()
11+ */
12+ public $ name ;
13+
14+ /**
15+ * @Assert\NotBlank()
16+ */
17+ public $ fieldNotUsedInTheForm ;
18+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Matthias \SymfonyConsoleForm \Tests \Form ;
4+
5+ use Matthias \SymfonyConsoleForm \Tests \Form \Data \SecretRequiredField ;
6+ use Symfony \Component \Form \AbstractType ;
7+ use Symfony \Component \Form \Extension \Core \Type \SubmitType ;
8+ use Symfony \Component \Form \Extension \Core \Type \TextType ;
9+ use Symfony \Component \Form \FormBuilderInterface ;
10+ use Symfony \Component \OptionsResolver \OptionsResolver ;
11+ use Symfony \Component \Validator \Constraints \Length ;
12+
13+ class SecretRequiredFieldType extends AbstractType
14+ {
15+ public function buildForm (FormBuilderInterface $ builder , array $ options )
16+ {
17+ $ builder ->add (
18+ 'name ' ,
19+ TextType::class,
20+ [
21+ 'label ' => 'Your name ' ,
22+ ]
23+ );
24+ }
25+
26+ public function configureOptions (OptionsResolver $ resolver )
27+ {
28+ $ resolver ->setDefaults ([
29+ 'data_class ' => SecretRequiredField::class,
30+ ]);
31+ }
32+ }
Original file line number Diff line number Diff line change @@ -90,6 +90,14 @@ services:
9090 tags :
9191 - { name: console.command }
9292
93+ secret_required_field_command :
94+ class : Matthias\SymfonyConsoleForm\Tests\Command\PrintFormDataCommand
95+ arguments :
96+ - Matthias\SymfonyConsoleForm\Tests\Form\SecretRequiredFieldType
97+ - secret_required_field
98+ tags :
99+ - { name: console.command }
100+
93101framework :
94102 form :
95103 csrf_protection : true
You can’t perform that action at this time.
0 commit comments