Example #1
0
 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);
 }
Example #2
0
 /**
  * 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' => '|')));
 }
Example #3
0
 /**
  * @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);
 }
Example #4
0
 /**
  * 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);
 }