TbHtml::beginFormTb PHP Method

beginFormTb() public static method

Generates an open form tag.
public static beginFormTb ( string $layout = self::FORM_LAYOUT_VERTICAL, string $action = '', string $method = 'post', array $htmlOptions = [] ) : string
$layout string the form layout.
$action string the form action URL.
$method string form method (e.g. post, get).
$htmlOptions array additional HTML attributes.
return string the generated tag.
    public static function beginFormTb($layout = self::FORM_LAYOUT_VERTICAL, $action = '', $method = 'post', $htmlOptions = array())
    {
        if (!empty($layout)) {
            // refactor to not use a switch
            switch ($layout) {
                case self::FORM_LAYOUT_HORIZONTAL:
                    self::addCssClass('form-' . self::FORM_LAYOUT_HORIZONTAL, $htmlOptions);
                    break;
                case self::FORM_LAYOUT_INLINE:
                case self::FORM_LAYOUT_SEARCH:
                    self::addCssClass('form-' . self::FORM_LAYOUT_INLINE, $htmlOptions);
                    break;
                default:
                    self::addCssClass('form-' . $layout, $htmlOptions);
            }
        }
        return parent::beginForm($action, $method, $htmlOptions);
    }

Usage Example

Example #1
0
 /**
  * Initializes the widget.
  */
 public function init()
 {
     $this->attachBehavior('TbWidget', new TbWidget());
     $this->copyId();
     if ($this->stateful) {
         echo TbHtml::statefulFormTb($this->layout, $this->action, $this->method, $this->htmlOptions);
     } else {
         echo TbHtml::beginFormTb($this->layout, $this->action, $this->method, $this->htmlOptions);
     }
 }
All Usage Examples Of TbHtml::beginFormTb
TbHtml