Skip to content
This repository has been archived by the owner on Jul 10, 2020. It is now read-only.

Commit

Permalink
Merge pull request #187 from maurice2k/feature/custom-row-class
Browse files Browse the repository at this point in the history
Added ability to add custom row class
  • Loading branch information
neilime authored Nov 14, 2016
2 parents a5ec64d + 2d88ceb commit 6c762a9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/TwbBundle/Form/View/Helper/TwbBundleFormRow.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ public function getRowClassFromElement(\Zend\Form\ElementInterface $oElement)
) {
$sRowClass .= ' col-' . $sColumSize;
}

//Additional row class
if ($sAddRowClass = $oElement->getOption('twb-row-class')) {
$sRowClass .= ' ' . $sAddRowClass;
}
return $sRowClass;
}

Expand Down
13 changes: 13 additions & 0 deletions tests/TwbBundleTest/Form/View/Helper/TwbBundleFormRowTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,19 @@ public function testRenderRadiosWithHorizontalLayout()
$this->assertStringEqualsFile($this->expectedPath . 'radio-horizontal-layout.phtml', $this->formRowHelper->__invoke($oElement));
}

public function testRenderFormRowWithSpecificClass()
{
$oElement = new \Zend\Form\Element\Text('test-text', array(
'label' => 'Test text',
'column-size' => 'sm-10',
'label_attributes' => array('class' => 'col-sm-2'),
'twb-row-class' => 'my-row-class'
));

// Test content
$this->assertStringEqualsFile($this->expectedPath . 'row-class.phtml', $this->formRowHelper->__invoke($oElement));
}

public function testRenderInputWithHelpTextAndError()
{
$oElement = new \Zend\Form\Element\Text('input-text', array(
Expand Down
1 change: 1 addition & 0 deletions tests/_files/expected-rows/row-class.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<div class="form-group col-sm-10 my-row-class"><label class="col-sm-2">Test text</label><input type="text" name="test-text" class="form-control" value=""></div>

0 comments on commit 6c762a9

Please sign in to comment.