Model form binding in laravel 5.2

I read about model form binding https://laravelcollective.com/docs/5.0/html#form-model-binding

It is very convenient to fill in the DB values ​​in html form. I tried this and it works fantastic.

{{ Form::model($university,array('url' => admin_path('universities/edit'),'id' => 'add_university','name' =>'add_university','data-validate'=>"parsley")) }} {{ Form::label('university_name', 'University name',array('class'=>'control-label')) }} {{ Form::text('university_name')}} {{Form::close()}} 

But the problem is here, because I want to add more attributes to the input, like class CO, I use

 {{ Form::label('university_name', 'University name',array('class'=>'control-label')) }} {{ Form::text('university_name','',array('class' => 'form-control'))}} 

If I leave an empty value column, then nothing will be filled in the text box, and if I use like this

 {{ Form::label('university_name', 'University name',array('class'=>'control-label')) }} {{ Form::text('university_name',$university->university_name,array('class' => 'form-control'))}} 

Then what is the use of model binding. Please explain. Thanks

+5
source share
1 answer
 {{ Form::text('university_name','',array('class' => 'form-control'))}} 

It should be:

 {{ Form::text('university_name',null,array('class' => 'form-control'))}} 

'' means a valid string, not null.
thanks mathielo for helping me in grammar

+3
source

All Articles