Exemple #1
0
 /**
  * Initializes the widget.
  * This renders the form open tag.
  */
 public function init()
 {
     if (!isset($this->options['id'])) {
         $this->options['id'] = $this->getId();
     }
     if ($this->defaultClass) {
         Html::addCssClass($this->options, $this->defaultClass);
     }
     if ($this->ajax) {
         Html::addCssClass($this->options, 'ajaxform');
     }
     switch ($this->type) {
         case self::TYPE_HORIZONTAL:
             if ($this->stripped) {
                 Html::addCssClass($this->options, 'form-row-stripped');
             }
             if ($this->separated) {
                 Html::addCssClass($this->options, 'form-row-seperated');
             }
             if ($this->bordered) {
                 Html::addCssClass($this->options, 'form-bordered');
             }
             Html::addCssClass($this->options, 'form-horizontal');
             $this->fieldConfig = ArrayHelper::merge(['labelOptions' => ['class' => 'col-md-' . $this->labelSpan . ' control-label'], 'template' => "{label}\n" . Html::tag('div', "{input}\n{hint}\n{error}", ['class' => 'col-md-' . ($this->fullSpan - $this->labelSpan)])], $this->fieldConfig);
             if (false) {
                 // wlchere - need to play with this once we know how the templates work out perhaps this needs to be an active field thing
                 // only useful because the hint and error blocks take up space even when no error or hint exists
                 $this->fieldConfig['template'] = str_replace("\n{error}", '', $this->fieldConfig['template']);
             }
             break;
         case self::TYPE_INLINE:
             Html::addCssClass($this->options, 'form-inline');
             $this->fieldConfig = ArrayHelper::merge(['labelOptions' => ['class' => 'sr-only']], $this->fieldConfig);
             break;
     }
     if (!isset($this->fieldConfig['class'])) {
         $this->fieldConfig['class'] = ActiveField::className();
     }
     if ($this->fake) {
         echo Html::beginTag('div', $this->options);
     } else {
         echo Html::beginForm($this->action, $this->method, $this->options);
     }
     echo $this->renderActions(self::BUTTONS_POSITION_TOP);
     echo Html::beginTag('div', ['class' => 'form-body']);
 }