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 #154 from BnitoBzh/patch-2
Browse files Browse the repository at this point in the history
Add inline option on Radio Element
  • Loading branch information
neilime committed Aug 24, 2015
2 parents 4cbe576 + ece8f0d commit 0e49644
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ $this->formRadio(new \Zend\Form\Element\ElementInterface());
```
This helper accepts an element as first param.
The option `disable-twb` (boolean) can be passed to the element to disable rendering it in a `div` container.
The option `inline` (boolean) can be passed to the element to display radio inlined or not (default).

#### Form row : `TwbBundle\Form\View\Helper\TwbBundleFormRow`

Expand Down
12 changes: 11 additions & 1 deletion src/TwbBundle/Form/View/Helper/TwbBundleFormRadio.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,23 @@ class TwbBundleFormRadio extends FormRadio
*/
public function render(ElementInterface $oElement)
{
if ($oElement->getOption('disable-twb')) {
$aElementOptions = $oElement->getOptions();

if (isset($aElementOptions['disable-twb']) && $aElementOptions['disable-twb'] == true) {
$sSeparator = $this->separator;
$this->separator = '';
$sReturn = parent::render($oElement);
$this->separator = $sSeparator;
return $sReturn;
}

if (isset($aElementOptions['inline']) && $aElementOptions['inline'] == true) {
$this->setSeparator('');
$oElement->setLabelAttributes(array('class' => 'radio-inline'));

return sprintf('%s', parent::render($oElement));
}

return sprintf(self::$checkboxFormat, parent::render($oElement));
}

Expand Down

0 comments on commit 0e49644

Please sign in to comment.