Skip to content
This repository has been archived by the owner on Feb 26, 2018. It is now read-only.

Commit

Permalink
Merge pull request #78 from Propaganistas/master
Browse files Browse the repository at this point in the history
Add form-group methods
  • Loading branch information
adamwathan committed Dec 8, 2015
2 parents ac369da + b85360d commit 9da1893
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/AdamWathan/BootForms/Elements/GroupWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
21 changes: 21 additions & 0 deletions tests/BasicFormBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,27 @@ public function testCanHideLabels()
$this->assertEquals($expected, $result);
}

public function testCanAddGroupClass()
{
$expected = '<div class="form-group test-class"><label class="control-label" for="email">Email</label><input type="text" name="email" id="email" class="form-control"></div>';
$result = $this->form->text('Email', 'email')->addGroupClass('test-class')->render();
$this->assertEquals($expected, $result);
}

public function testCanRemoveGroupClass()
{
$expected = '<div><label class="control-label" for="email">Email</label><input type="text" name="email" id="email" class="form-control"></div>';
$result = $this->form->text('Email', 'email')->removeGroupClass('form-group')->render();
$this->assertEquals($expected, $result);
}

public function testCanSetGroupData()
{
$expected = '<div class="form-group" data-test="1"><label class="control-label" for="email">Email</label><input type="text" name="email" id="email" class="form-control"></div>';
$result = $this->form->text('Email', 'email')->groupData('test', 1)->render();
$this->assertEquals($expected, $result);
}

public function testRenderInputGroupWithBeforeAddon()
{
$expected = '<div class="form-group"><label class="control-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>';
Expand Down

0 comments on commit 9da1893

Please sign in to comment.