File tree Expand file tree Collapse file tree
src/TypiCMS/BootForms/Elements Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,12 +31,12 @@ public function type($type)
3131 return $ this ;
3232 }
3333
34- protected function renderAddons ($ addons )
34+ protected function renderAddons ($ addons, $ class )
3535 {
3636 $ html = '' ;
3737
3838 foreach ($ addons as $ addon ) {
39- $ html .= '<span class="input-group-addon "> ' ;
39+ $ html .= sprintf ( '<span class="input-group-%s "> ' , $ class ) ;
4040 $ html .= $ addon ;
4141 $ html .= '</span> ' ;
4242 }
@@ -47,9 +47,9 @@ protected function renderAddons($addons)
4747 public function render ()
4848 {
4949 $ html = '<div class="input-group"> ' ;
50- $ html .= $ this ->renderAddons ($ this ->beforeAddon );
50+ $ html .= $ this ->renderAddons ($ this ->beforeAddon , ' prepend ' );
5151 $ html .= parent ::render ();
52- $ html .= $ this ->renderAddons ($ this ->afterAddon );
52+ $ html .= $ this ->renderAddons ($ this ->afterAddon , ' append ' );
5353 $ html .= '</div> ' ;
5454
5555 return $ html ;
Original file line number Diff line number Diff line change @@ -563,21 +563,21 @@ public function testCanSetGroupData()
563563
564564 public function testRenderInputGroupWithBeforeAddon ()
565565 {
566- $ expected = '<div class="form-group"><label for="username">Username</label><div class="input-group"><span class="input-group-addon ">@</span><input type="text" name="username" id="username" class="form-control"></div></div> ' ;
566+ $ expected = '<div class="form-group"><label for="username">Username</label><div class="input-group"><span class="input-group-prepend ">@</span><input type="text" name="username" id="username" class="form-control"></div></div> ' ;
567567 $ result = $ this ->form ->inputGroup ('Username ' , 'username ' )->beforeAddon ('@ ' )->render ();
568568 $ this ->assertEquals ($ expected , $ result );
569569 }
570570
571571 public function testRenderInputGroupWithAfterAddon ()
572572 {
573- $ expected = '<div class="form-group"><label for="site">Site</label><div class="input-group"><input type="text" name="site" id="site" class="form-control"><span class="input-group-addon ">.com.br</span></div></div> ' ;
573+ $ expected = '<div class="form-group"><label for="site">Site</label><div class="input-group"><input type="text" name="site" id="site" class="form-control"><span class="input-group-append ">.com.br</span></div></div> ' ;
574574 $ result = $ this ->form ->inputGroup ('Site ' , 'site ' )->afterAddon ('.com.br ' )->render ();
575575 $ this ->assertEquals ($ expected , $ result );
576576 }
577577
578578 public function testRenderInputGroupChangeTypeWithBothAddon ()
579579 {
580- $ expected = '<div class="form-group"><label for="secret">Secret</label><div class="input-group"><span class="input-group-addon ">before</span><input type="password" name="secret" id="secret" class="form-control"><span class="input-group-addon ">after</span></div></div> ' ;
580+ $ expected = '<div class="form-group"><label for="secret">Secret</label><div class="input-group"><span class="input-group-prepend ">before</span><input type="password" name="secret" id="secret" class="form-control"><span class="input-group-append ">after</span></div></div> ' ;
581581 $ result = $ this ->form
582582 ->inputGroup ('Secret ' , 'secret ' )
583583 ->type ('password ' )
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ public function testCanRenderBeforeAddon()
2020 $ input = new InputGroup ('username ' );
2121 $ this ->assertEquals ($ input , $ input ->beforeAddon ('@ ' ));
2222
23- $ expected = '<div class="input-group"><span class="input-group-addon ">@</span><input type="text" name="username"></div> ' ;
23+ $ expected = '<div class="input-group"><span class="input-group-prepend ">@</span><input type="text" name="username"></div> ' ;
2424 $ result = $ input ->render ();
2525 $ this ->assertEquals ($ expected , $ result );
2626 }
@@ -31,7 +31,7 @@ public function testCanRenderAfterAddonAndType()
3131 $ this ->assertEquals ($ input , $ input ->type ('email ' ));
3232 $ this ->assertEquals ($ input , $ input ->afterAddon ('@domain.com ' ));
3333
34- $ expected = '<div class="input-group"><input type="email" name="mail"><span class="input-group-addon ">@domain.com</span></div> ' ;
34+ $ expected = '<div class="input-group"><input type="email" name="mail"><span class="input-group-append ">@domain.com</span></div> ' ;
3535 $ result = $ input ->render ();
3636 $ this ->assertEquals ($ expected , $ result );
3737 }
You can’t perform that action at this time.
0 commit comments