Skip to content

Commit

Permalink
Merge pull request #2 from jgrossi/add-group-id
Browse files Browse the repository at this point in the history
Add the possibility to set the group id from the element
  • Loading branch information
inxilpro authored Nov 13, 2018
2 parents 9adb5a1 + 97d8973 commit c4d5945
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Elements/GroupWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ public function addGroupClass($class)
return $this;
}

/**
* @param mixed $id
* @return $this
*/
public function setGroupId($id)
{
$this->formGroup->id($id);

return $this;
}

/**
* @param $class
* @return $this
Expand Down
7 changes: 7 additions & 0 deletions tests/BasicFormBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,13 @@ public function testCanAddGroupClass()
$this->assertEquals($expected, $result);
}

public function testCanSetGroupId()
{
$expected = '<div class="form-group" id="test-id"><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')->setGroupId('test-id')->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>';
Expand Down

0 comments on commit c4d5945

Please sign in to comment.