6

I am doing simple cms in laravel 4.1 , i created many form and they working fine, but the last form which i create throws error on submit.

Illuminate \ Database \ Eloquent \ MassAssignmentException
_token

The data posted by form also show on error page.

_token  KLlDjuFgaEmuGHKMpFjqSrukYT3sawOYYZLPGxnb
name    asdf
body    asdfasdfa
bio sdfasdf

So its mean the _token is also posted then why i am getting this error.

My form look like this.

{{ Form::open(array('route' => 'admin.teachers.store','files'=>true)) }}
    <ul>
        <li>
            {{ Form::label('image', 'Image:') }}
            {{ Form::file('image') }}
        </li>

        <li>
            {{ Form::label('name', 'Name:') }}
            {{ Form::text('name') }}
        </li>

        <li>
            {{ Form::label('body', 'Body:') }}
            {{ Form::textarea('body',null,array('class'=>'ckeditor')) }}
        </li>

         <li>
            {{ Form::label('bio', 'Bio:') }}
            {{ Form::textarea('bio',null,array('class'=>'ckeditor')) }}
        </li>



        <li>
            {{ Form::submit('Submit', array('class' => 'btn btn-info')) }}
        </li>
    </ul>
{{ Form::close() }}

I see one related question to _token issue on forum but it didn't help me.

Thanks in advance :)

Community
  • 1
  • 1
Dexture
  • 976
  • 1
  • 11
  • 29

1 Answers1

17

In fact your error is MassAssignmentException, which means that you are using

Model::create($input);

In your controller and not using

protected $fillable = array('columnA', 'name'...);

or

protected $guarded = array();

In your Model, to tell Laravel which fields of your table are mass assignable.

Take a look at the docs: http://laravel.com/docs/eloquent#mass-assignment

Michiel
  • 2,143
  • 1
  • 21
  • 21
Antonio Carlos Ribeiro
  • 86,191
  • 22
  • 213
  • 204
  • You are right :) and perfect. i fix it after comparing that specific model with others model. was about to answer my question but your come first :) – Dexture Mar 11 '14 at 15:25