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 | |
$template | yii\gii\components\ActiveField |
Public Methods
Method | Description | Defined By |
---|---|---|
autoComplete() | Makes field auto completable | yii\gii\components\ActiveField |
checkbox() | yii\gii\components\ActiveField | |
hint() | yii\gii\components\ActiveField | |
init() | yii\gii\components\ActiveField | |
radio() | 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)
{
$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;
}
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);
}
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;
}
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}'] = '';
}
}
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);
}