本文整理汇总了PHP中CActiveForm::checkBoxList方法的典型用法代码示例。如果您正苦于以下问题:PHP CActiveForm::checkBoxList方法的具体用法?PHP CActiveForm::checkBoxList怎么用?PHP CActiveForm::checkBoxList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CActiveForm
的用法示例。
在下文中一共展示了CActiveForm::checkBoxList方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkBoxListWithSelectOnLabel
public function checkBoxListWithSelectOnLabel($model, $attribute, $data, $htmlOptions = array())
{
$htmlOptions['data-attribute'] = $attribute;
if (isset($htmlOptions['labelOptions']['class']) && $htmlOptions['labelOptions']['class']) {
$htmlOptions['labelOptions']['class'] .= ' checkbox-enabler attribute-' . $attribute;
} else {
$htmlOptions['labelOptions']['class'] = 'checkbox-enabler attribute-' . $attribute;
}
/** @var $cs CClientScript */
$cs = Yii::app()->getClientScript();
$cs->registerScript('checkBoxListWithSelectOnLabel-' . $attribute, "\n\t\t\t\t\$('.checkbox-enabler.attribute-" . $attribute . "').on('click', function(e) {\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\$('[data-attribute=\"" . $attribute . "\"]').attr('checked', false);\n\t\t\t\t\t\$('#' + \$(this).attr('for')).attr('checked', true);\n\t\t\t\t\t\$('#' + \$(this).attr('for')).trigger('change');\n\t\t\t\t});\n\t\t\t");
return parent::checkBoxList($model, $attribute, $data, $htmlOptions);
}
示例2: explodeCheckBoxList
/**
* Explodes checkBoxList into array
* enabling to render boxes separately ($box[0], $box[1]...)
* @param CActiveForm $form the form widgets
* @param CModel $model the data model
* @param string $attribute the attribute
* @param array $data value-label pairs used to generate the check box list.
* @return array of check boxes
*/
public static function explodeCheckBoxList($form, $model, $attribute, $data)
{
return explode('|', $form->checkBoxList($model, $attribute, $data, array('template' => '{input}{label}', 'separator' => '|')));
}
示例3: checkBoxList
/**
* @inheritDoc
*/
public function checkBoxList($model, $attribute, $data, $htmlOptions = array())
{
if (!$this->qualifyNames && !isset($htmlOptions['name'])) {
$htmlOptions['name'] = $attribute;
}
if (!isset($htmlOptions['itemprop'])) {
$htmlOptions['itemprop'] = $this->getItemPropName($attribute);
}
return parent::checkBoxList($model, $attribute, $data, $htmlOptions);
}
示例4: checkBoxList
/**
* Renders a checkbox list for a model attribute.
* @param CModel $parentModel the parent data model
* @param string $attributedPath the attribute or path to related model attribute
* @param array $data value-label pairs used to generate the check box list.
* @param array $htmlOptions additional HTML options.
* @return string the generated check box list
*/
public function checkBoxList($parentModel, $attributedPath, $data, $htmlOptions = array())
{
list($model, $attribute, $htmlOptions) = self::resolveArgs($parentModel, $attributedPath, $htmlOptions);
return parent::checkBoxList($model, $attribute, $data, $htmlOptions);
}