yii\widgets\ActiveField::begin PHP Метод

begin() публичный Метод

Renders the opening tag of the field container.
public begin ( ) : string
Результат string the rendering result.
    public function begin()
    {
        if ($this->form->enableClientScript) {
            $clientOptions = $this->getClientOptions();
            if (!empty($clientOptions)) {
                $this->form->attributes[] = $clientOptions;
            }
        }
        $inputID = $this->getInputId();
        $attribute = Html::getAttributeName($this->attribute);
        $options = $this->options;
        $class = isset($options['class']) ? [$options['class']] : [];
        $class[] = "field-{$inputID}";
        if ($this->model->isAttributeRequired($attribute)) {
            $class[] = $this->form->requiredCssClass;
        }
        if ($this->model->hasErrors($attribute)) {
            $class[] = $this->form->errorCssClass;
        }
        $options['class'] = implode(' ', $class);
        $tag = ArrayHelper::remove($options, 'tag', 'div');
        return Html::beginTag($tag, $options);
    }

Usage Example

Пример #1
0
 public function begin()
 {
     if ($this->collapsed == true) {
         $this->options["class"] .= " collapsed-box";
     }
     return parent::begin();
 }
All Usage Examples Of yii\widgets\ActiveField::begin