diff --git a/build/logs/clover.xml b/build/logs/clover.xml new file mode 100644 index 0000000..0649d0f --- /dev/null +++ b/build/logs/clover.xml @@ -0,0 +1,572 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/AdamWathan/BootForms/Elements/InputGroup.php b/src/AdamWathan/BootForms/Elements/InputGroup.php index 6cadad8..5dead6c 100644 --- a/src/AdamWathan/BootForms/Elements/InputGroup.php +++ b/src/AdamWathan/BootForms/Elements/InputGroup.php @@ -5,8 +5,9 @@ class InputGroup extends Text { protected $beforeAddon = []; - protected $afterAddon = []; + protected $classAddon; + protected $addonID; public function beforeAddon($addon) { @@ -22,6 +23,20 @@ public function afterAddon($addon) return $this; } + public function addAddonClass($class) + { + $this->classAddon = $class; + + return $this; + } + + public function addAddonId($id) + { + $this->addonID = $id; + + return $this; + } + public function type($type) { $this->attributes['type'] = $type; @@ -33,14 +48,19 @@ protected function renderAddons($addons) $html = ''; foreach ($addons as $addon) { - $html .= ''; - $html .= $addon; - $html .= ''; + $html .= sprintf('%s', $this->renderAddonsId(), $this->classAddon, $addon); } return $html; } + protected function renderAddonsId() + { + if($this->addonID) { + return sprintf('id = "%s"', $this->addonID); + } + } + public function render() { $html = '
'; diff --git a/tests/InputGroupTest.php b/tests/InputGroupTest.php index 6a15ef4..3444e0c 100644 --- a/tests/InputGroupTest.php +++ b/tests/InputGroupTest.php @@ -67,4 +67,21 @@ public function testDefaultValue() $result = $input->defaultValue('abc')->value('xyz')->render(); $this->assertEquals($expected, $result); } + + public function testCustomCssAddons() + { + $input = new InputGroup('example1'); + $input->afterAddon('@domain.com')->addAddonCss('newCss'); + + $expected = '
@domain.com
'; + $result = $input->render(); + $this->assertEquals($expected, $result); + + $input = new InputGroup('example2'); + $input->afterAddon('@domain.com')->addAddonCss('newCss1')->addAddonCss('newCss2'); + + $expected = '
@domain.com
'; + $result = $input->render(); + $this->assertEquals($expected, $result); + } }