LaravelCollective / docs

Documentation for LaravelCollective Packages
158 stars 103 forks source link

Form Model binding - could use more details around options #9

Closed jackfruh closed 8 years ago

jackfruh commented 9 years ago

Hi, I'm not sure if this is the right place to request this, but the Section #Form Model Binding could use some examples/clarifications around other options -ie how do we specify the class when this method of creating a form is used.

When it comes to the form element, there isn't anything about assigning a class anywhere in the docs. There's a mention of it under #Labels, as the 3rd parameter. Can it be used as the 3rd parameter in the form model binding?

Any clarification you can provide would be helpful - I tried figuring it out from the source code, but wasn't even sure where to start - Attributes maybe?

tshafer commented 9 years ago

When creating a form model you can add attributes in an array as the second parameter

   public function model($model, array $options = array())
   {
      $this->model = $model;
      return $this->open($options);
   }

You can do something like

echo Form::model($user, ['route' =>['user.update', $user->id], 'method' => 'patch',  'class' => 'foo bar']))
redgluten commented 8 years ago

Already in the docs (see “Specifying extra attributes”)