diff --git a/src/AdamWathan/BootForms/Elements/GroupWrapper.php b/src/AdamWathan/BootForms/Elements/GroupWrapper.php index f328baf..3024c25 100644 --- a/src/AdamWathan/BootForms/Elements/GroupWrapper.php +++ b/src/AdamWathan/BootForms/Elements/GroupWrapper.php @@ -27,6 +27,24 @@ public function __toString() return $this->render(); } + public function addGroupClass($class) + { + $this->formGroup->addClass($class); + return $this; + } + + public function removeGroupClass($class) + { + $this->formGroup->removeClass($class); + return $this; + } + + public function groupData($attribute, $value) + { + $this->formGroup->data($attribute, $value); + return $this; + } + public function labelClass($class) { $this->formGroup->label()->addClass($class); diff --git a/tests/BasicFormBuilderTest.php b/tests/BasicFormBuilderTest.php index 6bb3618..ad3658e 100644 --- a/tests/BasicFormBuilderTest.php +++ b/tests/BasicFormBuilderTest.php @@ -521,6 +521,27 @@ public function testCanHideLabels() $this->assertEquals($expected, $result); } + public function testCanAddGroupClass() + { + $expected = '
'; + $result = $this->form->text('Email', 'email')->addGroupClass('test-class')->render(); + $this->assertEquals($expected, $result); + } + + public function testCanRemoveGroupClass() + { + $expected = '
'; + $result = $this->form->text('Email', 'email')->removeGroupClass('form-group')->render(); + $this->assertEquals($expected, $result); + } + + public function testCanSetGroupData() + { + $expected = '
'; + $result = $this->form->text('Email', 'email')->groupData('test', 1)->render(); + $this->assertEquals($expected, $result); + } + public function testRenderInputGroupWithBeforeAddon() { $expected = '
@
';