Beispiel #1
0
 /**
  * Renders the opening tag of the field container.
  * @return string the rendering result.
  */
 public function begin()
 {
     if ($this->form->enableClientScript) {
         $clientOptions = $this->getClientOptions();
         if (!empty($clientOptions)) {
             $this->form->attributes[] = $clientOptions;
         }
     }
     $inputID = Html::getInputId($this->model, $this->attribute);
     $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);
 }
Beispiel #2
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     if (!isset($this->options['id'])) {
         $this->options['id'] = $this->getId();
     }
     if ($this->requiresPjax()) {
         ob_start();
         ob_implicit_flush(false);
         $view = $this->getView();
         $view->clear();
         $view->beginPage();
         $view->head();
         $view->beginBody();
         if ($view->title !== null) {
             echo Html::tag('title', Html::encode($view->title));
         }
     } else {
         echo Html::beginTag('div', $this->options);
     }
 }