yii\helpers\BaseHtml::checkbox PHP Method

checkbox() public static method

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.
return string the generated checkbox tag
    public static function checkbox($name, $checked = false, $options = [])
    {
        return static::booleanInput('checkbox', $name, $checked, $options);
    }

Usage Example

 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]);
 }
All Usage Examples Of yii\helpers\BaseHtml::checkbox