File tree Expand file tree Collapse file tree 6 files changed +52
-3
lines changed
Expand file tree Collapse file tree 6 files changed +52
-3
lines changed Original file line number Diff line number Diff line change @@ -12,13 +12,15 @@ class Builder
1212 'text ' => '/views/input-text.php ' ,
1313 'email ' => '/views/input-text.php ' ,
1414 'password ' => '/views/input-text.php ' ,
15- 'textarea ' => '/views/textarea.php '
15+ 'textarea ' => '/views/textarea.php ' ,
16+ 'dropdown ' => '/views/dropdown.php '
1617 ];
1718
1819 private $ optionalParameters = [
1920 'label ' ,
2021 'id ' ,
21- 'placeholder ' ,
22+ 'placeholder ' ,
23+ 'options ' ,
2224 'repeat ' ,
2325 'blockId '
2426 ];
Original file line number Diff line number Diff line change 4343 },
4444 "value" : {
4545 "description" : " The value attribute of the input" ,
46- "type" : " string"
46+ "type" : " string"
47+ },
48+ "options" : {
49+ "description" : " An array of key, value attribute of the input" ,
50+ "type" : " object"
4751 },
4852 "repeat" : {
4953 "description" : " Boolean value to make the input repetable" ,
Original file line number Diff line number Diff line change 1+ <?php
2+ // Template variables
3+ $ for = isset ($ id ) ? " for= \"$ id \"" : "" ;
4+ $ id = isset ($ id ) ? " id= \"$ id \"" : "" ;
5+ $ placeholder = isset ($ placeholder ) ? " placeholder= \"$ placeholder \"" : "" ;
6+ ?>
7+ <div class="form-group">
8+ <label<?= $ for ?> ><?= $ label ?> </label>
9+ <select class="form-control" name="<?= $ name ?> "<?= $ placeholder . $ id ?> >
10+ <?php foreach ($ options as $ key => $ value ): ?>
11+ <option values="<?= $ key ?> "><?= $ value ?> </option>
12+ <?php endforeach ; ?>
13+ </select>
14+ </div>
Original file line number Diff line number Diff line change 1+ {
2+ "inputs" : [
3+ {
4+ "name" : " city" ,
5+ "type" : " dropdown" ,
6+ "options" : {
7+ "1" : " Lima" ,
8+ "2" : " Arequipa"
9+ }
10+ }
11+ ]
12+ }
Original file line number Diff line number Diff line change 1+ < div class ="form-group ">
2+ < label > City</ label >
3+ < select class ="form-control " name ="city ">
4+ < option values ="1 "> Lima</ option >
5+ < option values ="2 "> Arequipa</ option >
6+ </ select >
7+ </ div >
Original file line number Diff line number Diff line change @@ -192,4 +192,14 @@ public function testCustomTextarea()
192192 private function flatString ($ str ) {
193193 return preg_replace ('/\s*/m ' , '' , $ str );
194194 }
195+
196+ public function testInputSimpleDropDown ()
197+ {
198+ $ microForm = file_get_contents (dirname (__FILE__ ) . '/../../../data/simple/dropdown-menu-tpl.json ' );
199+ $ expectedRendering = dirname (__FILE__ ) . '/../../../data/simple/dropdown-menu.html ' ;
200+
201+ $ builder = new \micro \form \Builder ();
202+ $ form = $ builder ->render ($ microForm );
203+ $ this ->string ($ form )->isEqualToContentsOfFile ($ expectedRendering );
204+ }
195205}
You can’t perform that action at this time.
0 commit comments