checkbox() публичный статический Метод

Generates a checkbox input.
public static checkbox ( string $name, boolean $checked = false, array $options = [] ) : string
$name string the name attribute.
$checked boolean whether the checkbox should be checked.
$options array the tag options in terms of name-value pairs. See [[booleanInput()]] for details about accepted attributes.
Результат string the generated checkbox tag
 public function renderDataCellContent($model, $key, $index)
 {
     // Set the attribute in a nice variable that we can use
     $sAttribute = $this->attribute;
     // Does the field have the unset value
     if ($model->{$sAttribute} == $this->unsetValue) {
         return BaseHtml::checkbox('actionColumChecbox', false, ['data-id' => $model->id, 'class' => 'checkActionColumn', 'data-saveurl' => $this->setUrl]);
     }
     $this->setContent = Yii::$app->formatter->asDatetime($model->{$sAttribute}, 'medium');
     // Return the set content
     return strtr($this->setTemplate, ['{check}' => $this->setCheck, '{content}' => $this->setContent]);
 }
Пример #2
0
 /**
  * @inheritdoc
  */
 public static function checkbox($name, $checked = false, $options = [])
 {
     if (!isset($options['id'])) {
         $options['id'] = Widget::$autoIdPrefix . Widget::$counter++;
     }
     $content = parent::checkbox($name, $checked, array_merge($options, ['label' => null]));
     if (isset($options['label'])) {
         $label = $options['label'];
         $for = $options['id'];
         $labelOptions = isset($options['labelOptions']) ? $options['labelOptions'] : [];
         unset($options['label'], $options['labelOptions']);
         $content .= parent::label($label, $for, $labelOptions);
     }
     return $content;
 }