File tree Expand file tree Collapse file tree 7 files changed +98
-2
lines changed Expand file tree Collapse file tree 7 files changed +98
-2
lines changed Original file line number Diff line number Diff line change 20
20
"symfony/property-access" : " 7.0.*" ,
21
21
"symfony/runtime" : " 7.0.*" ,
22
22
"symfony/twig-bundle" : " 7.0.*" ,
23
+ "symfony/validator" : " 7.0.*" ,
23
24
"symfony/yaml" : " 7.0.*" ,
24
25
"twig/extra-bundle" : " ^3.0" ,
25
26
"twig/string-extra" : " ^3.0" ,
Original file line number Diff line number Diff line change
1
+ framework :
2
+ validation :
3
+ # Enables validator auto-mapping support.
4
+ # For instance, basic validation constraints will be inferred from Doctrine's metadata.
5
+ # auto_mapping:
6
+ # App\Entity\: []
7
+
8
+ when@test :
9
+ framework :
10
+ validation :
11
+ not_compromised_password : false
Original file line number Diff line number Diff line change 5
5
namespace App \Controller ;
6
6
7
7
use App \Application \ConfigApplication ;
8
+ use App \Form \TopAsForm ;
8
9
use Symfony \Bundle \FrameworkBundle \Controller \AbstractController ;
10
+ use Symfony \Component \Form \FormView ;
11
+ use Symfony \Component \HttpFoundation \Request ;
9
12
use Symfony \Component \HttpFoundation \RequestStack ;
10
13
11
14
abstract class BaseController extends AbstractController
@@ -51,4 +54,12 @@ private function getBaseData(
51
54
];
52
55
}
53
56
}
57
+
58
+ public function addFormTopAs (Request $ request ): FormView
59
+ {
60
+ $ form = $ this ->createForm (TopAsForm::class);
61
+ $ form ->handleRequest ($ request );
62
+
63
+ return $ form ->createView ();
64
+ }
54
65
}
Original file line number Diff line number Diff line change @@ -68,6 +68,7 @@ public function index(
68
68
'knownlinks ' => KnowlinksRepository::get (),
69
69
'form ' => [
70
70
'legend ' => $ form ->createView (),
71
+ 'top ' => $ this ->addFormTopAs ($ request ),
71
72
],
72
73
]);
73
74
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ namespace App \Form ;
6
+
7
+ use Symfony \Component \Form \AbstractType ;
8
+ use Symfony \Component \Form \Extension \Core \Type \IntegerType ;
9
+ use Symfony \Component \Form \FormBuilderInterface ;
10
+ use Symfony \Component \OptionsResolver \OptionsResolver ;
11
+ use Symfony \Component \Validator \Constraints \Range ;
12
+
13
+ class TopAsForm extends AbstractType
14
+ {
15
+ /**
16
+ * @param array<string, mixed> $options
17
+ */
18
+ public function buildForm (FormBuilderInterface $ builder , array $ options ): void
19
+ {
20
+ $ builder
21
+ ->setMethod ('get ' )
22
+ ->add ('top ' , IntegerType::class, [
23
+ 'label ' => false ,
24
+ 'translation_domain ' => false ,
25
+ 'attr ' => [
26
+ 'placeholder ' => 'Top AS ' ,
27
+ ],
28
+ 'constraints ' => [
29
+ new Range (
30
+ notInRangeMessage: 'Value between {{ min }} and {{ max }}. ' ,
31
+ min: 1 ,
32
+ max: 200
33
+ ),
34
+ ],
35
+ ]);
36
+ }
37
+
38
+ public function getBlockPrefix (): string
39
+ {
40
+ return '' ;
41
+ }
42
+
43
+ public function configureOptions (OptionsResolver $ resolver ): void
44
+ {
45
+ $ resolver ->setDefaults ([
46
+ 'csrf_protection ' => false ,
47
+ ]);
48
+ }
49
+ }
Original file line number Diff line number Diff line change 119
119
"templates/base.html.twig"
120
120
]
121
121
},
122
+ "symfony/validator": {
123
+ "version": "7.0",
124
+ "recipe": {
125
+ "repo": "github.com/symfony/recipes",
126
+ "branch": "main",
127
+ "version": "7.0",
128
+ "ref": "8c1c4e28d26a124b0bb273f537ca8ce443472bfd"
129
+ },
130
+ "files": [
131
+ "config/packages/validator.yaml"
132
+ ]
133
+ },
122
134
"symfony/web-profiler-bundle": {
123
135
"version": "7.0",
124
136
"recipe": {
Original file line number Diff line number Diff line change 11
11
12
12
<div class =" navbar-nav flex-row order-md-last" >
13
13
<div class =" my-1 flex-grow-1 flex-md-grow-0 order-first" >
14
- <form method =" get" autocomplete =" off" novalidate =" " >
14
+ <!-- < form method="get" autocomplete="off" novalidate="">
15
15
<div class="input-icon">
16
16
<span class="input-icon-addon">
17
17
{{ icon(' filter' ) }}
18
18
</span>
19
19
<input type="number" name='top' min=1 class="form-control" value="{{ base_data .request .top | default (' ' ) }}" placeholder="Top AS">
20
20
</div>
21
- </form >
21
+ </form>-->
22
+ {% if form .top is defined %}
23
+ {{ form_start(form .top ) }}
24
+ <div class =" input-icon" >
25
+ <span class =" input-icon-addon" >
26
+ {{ icon(' filter' ) }}
27
+ </span >
28
+ {{ form_widget(form .top .top , {value : base_data .request .top |default (' ' )}) }}
29
+ </div >
30
+ {{ form_errors(form .top .top ) }}
31
+ {{ form_end(form .top ) }}
32
+ {% endif %}
22
33
</div >
23
34
</div >
24
35
You can’t perform that action at this time.
0 commit comments