yiisoft/yii — pull request #373 by mikehaertl (2012-02-19 14:39:58+00:00)
Title: Let labels in CHtml optionally wrap input elements

This change allows all `` tags to optionally wrap an input element. The change affects all checkbox and radiobutton derivates.

* `CHtml::$labelWrapInputs`. If turned on, all radioButtonLists and checkBoxLists will render with lables wrapping the input element. Off by default, so this change is backwards compatible.

* `CHtml::label` and `CHtml::activeLabel` have 2 new `htmlOptions`: `wrapInput` (wraps input element, which can be specified in `$for`) and `template` which defaults to `'{input} {label}'`

```php
,'
array('wrapInput'=>true)
) ?>
```

Gives ` test`.

* Because almost every checkbox or radio button need a label, this is was now included into `CHtml::checkBox` and `CHtml::radioButton`. Both have new `htmlOptions` `label` and `labelOptions`. If set, a label will automatically be rendered. A template can be specified in `labelOptions` (see `CHtml::label`). This change was neccessary to play nice with hidden inputs. Inside a label tag must only be 1 input element. So the hidden element must be rendered outside.

```php
'Some label',
'labelOptions'=>array('template'=>'{label} - {input}'),
)); ?>
```
Gives ` - Some label`.

* New `htmlOptions` for `radioButtonList`, `checkBoxList` and their active derivates: `wrapInput`. Defaults to `CHtml::labelWrapInputs`.

```php

'Value 1',
2=>'Value 2',
)); ?>
```