How to pass attributes like id
, class
to form model?
This what i try not working and in official Laravel documentation wass not defined.
@if(isset($country))
{{ Form::model($country, ['route' => ['country.show', $country->id]], ['class' => "123"]) }}
@else
{{ Form::open(['route' => 'country.store', 'id'=> 'admin_store_form' ]) }}
@endif
<div >
<div >
{{ Form::label('name', 'Name', ['class' => 'col-sm-2 admin-label col-form-label']) }}
</div>
<div >
{{ Form::text('name', old('name'), ['placeholder'=>'Name', 'class' => 'form-control form-control-sm admin-control']) }}
</div>
</div>
{{ Form::close() }}
I define 'class' => "123"
but that not work.
CodePudding user response:
The correct way to add a class to Form::model
is:
{{ Form::model($country, ['route' => ['country.show', $country->id], 'class' => '123']) }}
You need to add the class
key to the same array argument as route
.