Class yii\gii\components\ActiveField
| Inheritance | yii\gii\components\ActiveField » yii\widgets\ActiveField | 
|---|---|
| Available since extension's version | 2.0 | 
| Source Code | https://github.com/yiisoft/yii2-gii/blob/master/src/components/ActiveField.php | 
Public Properties
| Property | Type | Description | Defined By | 
|---|---|---|---|
| $model | yii\gii\Generator | yii\gii\components\ActiveField | 
Public 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
Method Details
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;
}
            
        
| 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]);
        }
    }
}