2

I have the following code

$input = Input::all();
 return $input;

It returns all the data I entered in the form. Since all the data is available, I tried to insert data into database as

$this->agro->create($input);

When I check the database,the empty string is inserted. I am confused,why the data is not inserted when the $input is displaying the inserted data in the form. Please HELP!!!

EDIT

This is User Model

class User extends Eloquent implements UserInterface, RemindableInterface {

    use UserTrait, RemindableTrait;

    public $timestamps = false;

    protected $fillable = ['title','content','author'];

    protected $table = 'tbl_article';
}

And this is my form

 {{@Form::open(['route'=>'agrovet.store'])}}

 <div>
 {{ @Form::label('lbl_title','Title') }}
 {{ @Form::text('title') }}
 </div>

 <div>
 {{ @Form::label('lbl_content','Content') }}
 {{ @Form::text('content') }}
 </div>

 <div>
 {{ @Form::label('lbl_author','Author') }}
 {{ @Form::text('author') }}
 </div>

 <div>
 {{ @form::submit('submit')}}
 </div>
3
  • Is $fillable set correctly in your model? Mass Assignment Commented Feb 9, 2015 at 14:46
  • Yea it's protected $fillable = ['title','content','author']; Commented Feb 9, 2015 at 14:48
  • Hmm can you update your question with the model code and the dump of $input? Commented Feb 9, 2015 at 14:49

1 Answer 1

1

The names of your text inputs are wrong. You should use the same name as your model attributes (and labels)

{{ @Form::label('title','Title') }}
{{ @Form::text('title') }}

and the same for the others...

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks a lot..it had been killing me from quit sometime.Please can you tell me why is it So in laravel. I mean, I've never had such experience of using the same name for label and text before?
You're welcome. Well that's just basic HTML actually. The name you assign to the label doesn't really matter for the input the server get's. It is only needed so the browser knows which label belongs to which input.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.