Bootstrap\View\Helper\BootstrapFormHelper::create PHP Method

create() public method

New options available: - horizontal: boolean, specify if the form is horizontal - inline: boolean, specify if the form is inline - search: boolean, specify if the form is a search form Unusable options: - inputDefaults
public create ( $model = null, array $options = [] ) : The
$model The model corresponding to the form
$options array Options to customize the form
return The HTML tags corresponding to the openning of the form
    public function create($model = null, array $options = array())
    {
        $options += ['columns' => $this->config('columns'), 'horizontal' => false, 'inline' => false];
        $this->colSize = $options['columns'];
        $this->horizontal = $options['horizontal'];
        $this->inline = $options['inline'];
        unset($options['columns'], $options['horizontal'], $options['inline']);
        if ($this->horizontal) {
            $options = $this->addClass($options, 'form-horizontal');
        } else {
            if ($this->inline) {
                $options = $this->addClass($options, 'form-inline');
            }
        }
        $options['role'] = 'form';
        return parent::create($model, $options);
    }

Usage Example

Beispiel #1
0
 public function create($model = null, array $options = [])
 {
     if (is_null($model) or trim($model) == '') {
         $_id = 'MyFormCakePhp' . time();
         $options = ['id' => $_id, 'name' => $_id] + $options;
     }
     return parent::create($model, $options);
 }