Reputation: 67
I have a form in my blade template when I click submit button nothing is happing it is not going to my controller. this is the form
{{Form::open(['action' => ['HomeController@addcity'], 'method' => 'POST']) }}
{!! Form::select('city_add', array("CAM" => "CAM","KL" => "KL","IPOH" => "IPOH"), 'S',['style'=>'
}'],['class' => 'form-control','placeholder'=>'hotel_name']); !!}
{{Form::text('city_add',"CAM") }}
{{Form::submit('Submit',['class'=>'btn btn-danger'])}}
{!! Form::close() !!}
this is my route
Route::post('/home', 'HomeController@addcity');
My route controller
Upvotes: 0
Views: 341
Reputation: 2945
Your form select
element like below:
You should not use same name for the select tag and input tag.
{{Form::open(['action' => ['HomeController@addcity'], 'method' => 'POST']) }}
{!! Form::select('city_option', array("CAM" => "CAM","KL" => "KL","IPOH" => "IPOH"),['class' => 'form-control','placeholder'=>'hotel_name']); !!}
{{Form::text('city_add',"CAM") }}
{{Form::submit('Submit',['class'=>'btn btn-danger'])}}
{!! Form::close() !!}
And In controller( for the test )
public function addcity(Request $request )
{
echo '<pre>';
print_r($request->all());
exit();
}
if you would like to add style in form element use below code:
{{Form::open(['action' => ['HomeController@addcity'], 'method' => 'POST']) }}
{!! Form::select('city_option', array("CAM" => "CAM","KL" => "KL","IPOH" => "IPOH"),'S',['style'=>'color:red'],['class' => 'form-control','placeholder'=>'hotel_name']); !!}
{{Form::text('city_add',"CAM") }}
{{Form::submit('Submit',['class'=>'btn btn-danger'])}}
{!! Form::close() !!}
Upvotes: 1