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

Public Properties

Hide inherited properties

Property Type Description Defined By
$model yii\gii\Generator yii\gii\components\ActiveField

Public Methods

Hide inherited methods

Method Description Defined By
autoComplete() Makes field auto completable yii\gii\components\ActiveField
init() yii\gii\components\ActiveField
sticky() Makes field remember its value between page reloads yii\gii\components\ActiveField

Property Details

Hide inherited properties

$model public property
public yii\gii\Generator $model null

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)
{
    static $counter = 0;
    $this->inputOptions['class'] .= ' typeahead typeahead-' . (++$counter);
    foreach ($data as &$item) {
        $item = ['word' => $item];
    }
    $this->form->getView()->registerJs("yii.gii.autocomplete($counter, " . Json::htmlEncode($data) . ");");
    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]);
        }
    }
}

            
sticky() public method

Makes field remember its value between page reloads

public $this sticky ( )
return $this

The field object itself

                public function sticky()
{
    $this->options['class'] .= ' sticky';
    return $this;
}