File tree Expand file tree Collapse file tree 3 files changed +55
-0
lines changed Expand file tree Collapse file tree 3 files changed +55
-0
lines changed Original file line number Diff line number Diff line change @@ -146,3 +146,18 @@ Feature: It is possible to interactively fill in a form from the CLI
146146 [fieldName] => empty
147147 )
148148 """
149+
150+ Scenario : Provide no value with no default value, value should be asked again
151+ When I run the command "form:name_without_default_value" and I provide as input "[enter]Jelmer[enter]"
152+ And the output should contain
153+ """
154+ Your name: Invalid data provided: name:
155+ """
156+ And the output should contain
157+ """
158+ ERROR: This value should not be blank
159+ """
160+ And the output should contain
161+ """
162+ [name] => Jelmer
163+ """
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Matthias \SymfonyConsoleForm \Tests \Form ;
4+
5+ use Symfony \Component \Form \AbstractType ;
6+ use Symfony \Component \Form \Extension \Core \Type \SubmitType ;
7+ use Symfony \Component \Form \Extension \Core \Type \TextType ;
8+ use Symfony \Component \Form \FormBuilderInterface ;
9+ use Symfony \Component \Validator \Constraints \NotBlank ;
10+
11+ class NameWithoutDefaultValueType extends AbstractType
12+ {
13+ public function buildForm (FormBuilderInterface $ builder , array $ options )
14+ {
15+ $ builder ->add (
16+ 'name ' ,
17+ TextType::class,
18+ [
19+ 'label ' => 'Your name ' ,
20+ 'constraints ' => [
21+ new NotBlank (),
22+ ],
23+ ]
24+ )->add (
25+ 'submit ' ,
26+ SubmitType::class,
27+ [
28+ 'label ' => 'Submit ' ,
29+ ]
30+ );
31+ }
32+ }
Original file line number Diff line number Diff line change @@ -18,6 +18,14 @@ services:
1818 tags :
1919 - { name: console.command }
2020
21+ name_without_default_value_command :
22+ class : Matthias\SymfonyConsoleForm\Tests\Command\PrintFormDataCommand
23+ arguments :
24+ - Matthias\SymfonyConsoleForm\Tests\Form\NameWithoutDefaultValueType
25+ - name_without_default_value
26+ tags :
27+ - { name: console.command }
28+
2129 color_command :
2230 class : Matthias\SymfonyConsoleForm\Tests\Command\PrintFormDataCommand
2331 arguments :
You can’t perform that action at this time.
0 commit comments