Class yii\gii\components\ActiveField

Inheritanceyii\gii\components\ActiveField » yii\widgets\ActiveField
Available since extension's version2.0
Source Code https://github.com/yiisoft/yii2-gii/blob/master/src/components/ActiveField.php

Property Details

Hide inherited properties

$model public property
public yii\gii\Generator $model null
$template public property
public $template "{label}\n{input}\n{list}\n{error}"

Method Details

Hide inherited methods

autoComplete() public method

Makes field auto completable

public $this autoComplete ( $data )
$data array

Auto complete data (array of callables or scalars)

return $this

The field object itself

                public function autoComplete($data)
{
    $inputID = $this->getInputId();
    ArrayHelper::setValue($this->inputOptions, 'list', "$inputID-list");
    $html = Html::beginTag('datalist', ['id' => "$inputID-list"]) . "\n";
    foreach ($data as $item) {
        $html .= Html::tag('option', $item) . "\n";
    }
    $html .= Html::endTag('datalist');
    $this->parts['{list}'] = $html;
    return $this;
}

            
checkbox() public method

public void checkbox ( $options = [], $enclosedByLabel false )
$options
$enclosedByLabel

                public function checkbox($options = [], $enclosedByLabel = false)
{
    $this->template = "{input}\n{label}\n{error}";
    Html::addCssClass($this->options, 'form-check');
    Html::addCssClass($options, 'form-check-input');
    Html::addCssClass($this->labelOptions, 'form-check-label');
    return parent::checkbox($options, $enclosedByLabel);
}

            
hint() public method

public void hint ( $content, $options = [] )
$content
$options

                public function hint($content, $options = [])
{
    Html::addCssClass($this->labelOptions, 'help');
    ArrayHelper::setValue($this->labelOptions, 'data.toggle', 'popover');
    ArrayHelper::setValue($this->labelOptions, 'data.content', $content);
    ArrayHelper::setValue($this->labelOptions, 'data.placement', 'right');
    return $this;
}

            
init() public method

public void init ( )

                public function init()
{
    $stickyAttributes = $this->model->stickyAttributes();
    if (in_array($this->attribute, $stickyAttributes, true)) {
        $this->sticky();
    }
    $hints = $this->model->hints();
    if (isset($hints[$this->attribute])) {
        $this->hint($hints[$this->attribute]);
    }
    $autoCompleteData = $this->model->autoCompleteData();
    if (isset($autoCompleteData[$this->attribute])) {
        if (is_callable($autoCompleteData[$this->attribute])) {
            $this->autoComplete(call_user_func($autoCompleteData[$this->attribute]));
        } else {
            $this->autoComplete($autoCompleteData[$this->attribute]);
        }
    } else {
        $this->parts['{list}'] = '';
    }
}

            
radio() public method

public void radio ( $options = [], $enclosedByLabel false )
$options
$enclosedByLabel

                public function radio($options = [], $enclosedByLabel = false)
{
    $this->template = "{input}\n{label}\n{error}";
    Html::addCssClass($this->options, 'form-check');
    Html::addCssClass($options, 'form-check-input');
    Html::addCssClass($this->labelOptions, 'form-check-label');
    return parent::radio($options, $enclosedByLabel);
}

            
sticky() public method

Makes field remember its value between page reloads

public $this sticky ( )
return $this

The field object itself

                public function sticky()
{
    Html::addCssClass($this->options, 'sticky');
    return $this;
}