Generates an active form row.
public static activeControlGroup ( string $type, CModel $model, string $attribute, array $htmlOptions = [], array $data = [] ) : string | ||
$type | string | the input type. |
$model | CModel | the data model. |
$attribute | string | the attribute. |
$htmlOptions | array | additional HTML attributes. |
$data | array | data for multiple select inputs. |
return | string | the generated control group. |
/** * Renders a form control that is implemented via a widget. */ protected function renderWidget() { $input = parent::renderInput(); return TbHtml::activeControlGroup(null, $this->getParent()->getModel(), $this->name, array('input' => $input)); }
/** * Generates a control group for a model attribute. * @param string $type the input type. * @param CModel $model the data model. * @param string $attribute the attribute name. * @param array $htmlOptions additional HTML attributes. * @param array $data data for generating the list options (value=>display). * @return string the generated control group. * @see TbHtml::activeControlGroup */ public function createControlGroup($type, $model, $attribute, $htmlOptions = array(), $data = array()) { $htmlOptions = $this->processControlGroupOptions($model, $attribute, $htmlOptions); return TbHtml::activeControlGroup($type, $model, $attribute, $htmlOptions, $data); }
public function testActiveControlGroup() { $I = $this->codeGuy; $html = TbHtml::activeControlGroup(TbHtml::INPUT_TYPE_TEXT, new Dummy(), 'text', array('color' => TbHtml::INPUT_COLOR_ERROR, 'groupOptions' => array('class' => 'group'), 'labelOptions' => array('class' => 'label'), 'help' => 'Help text', 'helpOptions' => array('class' => 'help'))); $group = $I->createNode($html, 'div.control-group'); $I->seeNodeCssClass($group, 'error group'); $I->seeNodeChildren($group, array('label.control-label', 'div.controls')); $label = $group->filter('label.control-label'); $I->seeNodeCssClass($label, 'label'); $I->seeNodeAttribute($label, 'for', 'Dummy_text'); $I->seeNodeText($label, 'Text'); $controls = $group->filter('div.controls'); $I->seeNodeChildren($controls, array('input', 'span')); $input = $controls->filter('input[type=text]'); $I->seeNodeAttributes($input, array('id' => 'Dummy_text', 'name' => 'Dummy[text]', 'value' => 'text')); $help = $controls->filter('span.help-inline'); $I->seeNodeCssClass($help, 'help'); $I->seeNodeText($help, 'Help text'); $html = TbHtml::activeControlGroup(TbHtml::INPUT_TYPE_RADIOBUTTON, new Dummy(), 'radio', array('labelOptions' => array('class' => 'label'))); $group = $I->createNode($html, 'div.control-group'); $I->seeNodeChildren($group, array('div.controls')); $controls = $group->filter('div.controls'); $I->seeNodeChildren($controls, array('input[type=hidden]', 'label.radio')); $hidden = $controls->filter('input[type=hidden]'); $I->seeNodeAttributes($hidden, array('id' => 'ytDummy_radio', 'name' => 'Dummy[radio]', 'value' => '0')); $label = $controls->filter('label.radio'); $I->seeNodePattern($label, '/> Radio$/'); $radio = $label->filter('input[type=radio]'); $I->seeNodeAttributes($radio, array('checked' => 'checked', 'id' => 'Dummy_radio', 'name' => 'Dummy[radio]', 'value' => '1')); }