Skip to content

Commit a555180

Browse files
committed
Merge pull request #47 from wvdongen/master
Set label text without having to create array 'text' key.
2 parents 06d63a3 + 27135bf commit a555180

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

Test/Case/View/Helper/BoostCakeFormHelperTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -306,12 +306,12 @@ public function testRadio() {
306306
'Name',
307307
'/legend',
308308
array('input' => array('type' => 'hidden', 'name' => 'data[name]', 'id' => 'name_', 'value' => '')),
309-
array('label' => array('for' => 'NameOne', 'class' => 'radio')),
310-
array('input' => array('name' => 'data[name]', 'type' => 'radio', 'value' => 'one', 'id' => 'NameOne')),
309+
array('label' => array('for' => 'nameOne', 'class' => 'radio')),
310+
array('input' => array('name' => 'data[name]', 'type' => 'radio', 'value' => 'one', 'id' => 'nameOne')),
311311
' This is one',
312312
'/label',
313-
array('label' => array('for' => 'NameTwo', 'class' => 'radio')),
314-
array('input' => array('name' => 'data[name]', 'type' => 'radio', 'value' => 'two', 'id' => 'NameTwo')),
313+
array('label' => array('for' => 'nameTwo', 'class' => 'radio')),
314+
array('input' => array('name' => 'data[name]', 'type' => 'radio', 'value' => 'two', 'id' => 'nameTwo')),
315315
' This is two',
316316
'/label',
317317
'/fieldset',

View/Helper/BoostCakeFormHelper.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ public function input($fieldName, $options = array()) {
7676
'afterInput' => '',
7777
'errorClass' => 'has-error error'
7878
);
79+
80+
if (isset($options['label']) && is_string($options['label'])) {
81+
$options['label'] = array(
82+
'text' => $options['label']
83+
);
84+
}
7985

8086
$options = Hash::merge(
8187
$default,

0 commit comments

Comments
 (0)