Reputation: 17279
this below code is my profile managment form for users and i want to fill input
tags with $profile
variable .
{{ $profile }}
can echo all fields of user table. but i can not fill input
tags with this variable.
Result: {"id":"1","username":"mahdi","name":"Mahdi","family":"Pishguy","email":"[email protected]"}
My Form:
{{ Form::open(array('route' => 'admin.profile.update', $profile->id , 'method' => 'PUT','class'=>'navbar-form navbar-right', 'role' =>'search')) }}
<div class="form-group rtl">
<div>Your Username: <b> {{ $profile->username }} </b></div><br />
{{ Form::label('name' , 'name: ') }}
{{ Form::text('name', Input::old('name'), array('id'=>'email', 'class' => 'form-control')) }}
{{ Form::label('family' , 'family: ') }}
{{ Form::text('family', Input::old('family'), array('placeholder'=>'sss', 'id'=>'email', 'class' => 'form-control')) }}
<p>
{{ Form::submit('Submit', array('id'=>'submit','class'=>'btn btn-default' , 'style'=>'float:left')) }}
</p>
</div>
{{ Form::close() }}
Upvotes: 0
Views: 4286
Reputation: 4111
Thats easy, see the Form Model Binding in the docs
You code should be something like this:
{{ Form::model($profile, array('route' => 'admin.profile.update', $profile->id , 'method' => 'PUT','class'=>'navbar-form navbar-right', 'role' =>'search')) }}
<div class="form-group rtl">
<div>Your Username: <b> {{ $profile->username }} </b></div><br />
{{ Form::label('name' , 'name: ') }}
{{ Form::text('name', Input::old('name'), array('id'=>'email', 'class' => 'form-control')) }}
{{ Form::label('family' , 'family: ') }}
{{ Form::text('family', Input::old('family'), array('placeholder'=>'sss', 'id'=>'email', 'class' => 'form-control')) }}
<p>
{{ Form::submit('Submit', array('id'=>'submit','class'=>'btn btn-default' , 'style'=>'float:left')) }}
</p>
</div>
{{ Form::close() }}
NOTE: You can remove the Input::old()
stuf because this is handled by the Form::model()
Upvotes: 2