From 4acb5b92bb5128233cdb9bc4e3a5aa289745270b Mon Sep 17 00:00:00 2001 From: Nathan Dunn Date: Tue, 19 Feb 2019 15:02:44 +0000 Subject: [PATCH 1/2] Update InputGroup to use Bootstrap classes --- src/TypiCMS/BootForms/Elements/InputGroup.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/TypiCMS/BootForms/Elements/InputGroup.php b/src/TypiCMS/BootForms/Elements/InputGroup.php index 8c7155b..2e4362e 100644 --- a/src/TypiCMS/BootForms/Elements/InputGroup.php +++ b/src/TypiCMS/BootForms/Elements/InputGroup.php @@ -31,12 +31,12 @@ public function type($type) return $this; } - protected function renderAddons($addons) + protected function renderAddons($addons, $class) { $html = ''; foreach ($addons as $addon) { - $html .= ''; + $html .= sprintf('', $class); $html .= $addon; $html .= ''; } @@ -47,9 +47,9 @@ protected function renderAddons($addons) public function render() { $html = '
'; - $html .= $this->renderAddons($this->beforeAddon); + $html .= $this->renderAddons($this->beforeAddon, 'prepend'); $html .= parent::render(); - $html .= $this->renderAddons($this->afterAddon); + $html .= $this->renderAddons($this->afterAddon, 'append'); $html .= '
'; return $html; From 5843305e4e4ae694fbc9f60317b8538a478a148d Mon Sep 17 00:00:00 2001 From: Nathan Dunn Date: Tue, 19 Feb 2019 15:16:44 +0000 Subject: [PATCH 2/2] Update tests --- tests/BasicFormBuilderTest.php | 6 +++--- tests/InputGroupTest.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/BasicFormBuilderTest.php b/tests/BasicFormBuilderTest.php index f52e984..bef3256 100644 --- a/tests/BasicFormBuilderTest.php +++ b/tests/BasicFormBuilderTest.php @@ -563,21 +563,21 @@ public function testCanSetGroupData() public function testRenderInputGroupWithBeforeAddon() { - $expected = '
@
'; + $expected = '
@
'; $result = $this->form->inputGroup('Username', 'username')->beforeAddon('@')->render(); $this->assertEquals($expected, $result); } public function testRenderInputGroupWithAfterAddon() { - $expected = '
.com.br
'; + $expected = '
.com.br
'; $result = $this->form->inputGroup('Site', 'site')->afterAddon('.com.br')->render(); $this->assertEquals($expected, $result); } public function testRenderInputGroupChangeTypeWithBothAddon() { - $expected = '
beforeafter
'; + $expected = '
beforeafter
'; $result = $this->form ->inputGroup('Secret', 'secret') ->type('password') diff --git a/tests/InputGroupTest.php b/tests/InputGroupTest.php index 609da7f..57510b2 100644 --- a/tests/InputGroupTest.php +++ b/tests/InputGroupTest.php @@ -20,7 +20,7 @@ public function testCanRenderBeforeAddon() $input = new InputGroup('username'); $this->assertEquals($input, $input->beforeAddon('@')); - $expected = '
@
'; + $expected = '
@
'; $result = $input->render(); $this->assertEquals($expected, $result); } @@ -31,7 +31,7 @@ public function testCanRenderAfterAddonAndType() $this->assertEquals($input, $input->type('email')); $this->assertEquals($input, $input->afterAddon('@domain.com')); - $expected = '
@domain.com
'; + $expected = '
@domain.com
'; $result = $input->render(); $this->assertEquals($expected, $result); }