Skip to content

Commit

Permalink
Merge pull request #47 from wvdongen/master
Browse files Browse the repository at this point in the history
Set label text without having to create array 'text' key.
  • Loading branch information
slywalker committed Jan 9, 2014
2 parents 06d63a3 + 27135bf commit a555180
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Test/Case/View/Helper/BoostCakeFormHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -306,12 +306,12 @@ public function testRadio() {
'Name',
'/legend',
array('input' => array('type' => 'hidden', 'name' => 'data[name]', 'id' => 'name_', 'value' => '')),
array('label' => array('for' => 'NameOne', 'class' => 'radio')),
array('input' => array('name' => 'data[name]', 'type' => 'radio', 'value' => 'one', 'id' => 'NameOne')),
array('label' => array('for' => 'nameOne', 'class' => 'radio')),
array('input' => array('name' => 'data[name]', 'type' => 'radio', 'value' => 'one', 'id' => 'nameOne')),
' This is one',
'/label',
array('label' => array('for' => 'NameTwo', 'class' => 'radio')),
array('input' => array('name' => 'data[name]', 'type' => 'radio', 'value' => 'two', 'id' => 'NameTwo')),
array('label' => array('for' => 'nameTwo', 'class' => 'radio')),
array('input' => array('name' => 'data[name]', 'type' => 'radio', 'value' => 'two', 'id' => 'nameTwo')),
' This is two',
'/label',
'/fieldset',
Expand Down
6 changes: 6 additions & 0 deletions View/Helper/BoostCakeFormHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ public function input($fieldName, $options = array()) {
'afterInput' => '',
'errorClass' => 'has-error error'
);

if (isset($options['label']) && is_string($options['label'])) {
$options['label'] = array(
'text' => $options['label']
);
}

$options = Hash::merge(
$default,
Expand Down

0 comments on commit a555180

Please sign in to comment.