You have to use JavaScript
to fire the select's change
event and you may try this:
var select = document.getElementById('client_id');
select.addEventListener('change', function(){
this.form.submit();
}, false);
This will submit
the form
on change
event and you may also try this as well:
var select = document.getElementById('client_id');
select.onchange = function(){
this.form.submit();
};
Using jQuery
, you may try this:
$('#client_id').on('change', function(e){
$(this).closest('form').submit();
});
Or using inline event handling, you may try this (Add this in the attribute's array):
"onchange" => "this.form.submit()"
Above code will produce something like this:
<select onchange="this.form.submit()">
To generate the url
you may use this:
{{ Form::open(array('url' => 'user/' . $user->id, 'name' => "frm_select_client")) }}
Also, you may use route
like this (assumed user.show
is the route name for url user/{id}
):
{{ Form::open(array('route' => array('user.show', $user->id), 'name' => "frm_select_client")) }}
Make sure you pass the $user
object to your view
when loading the form, using something like this (Basically from a Controller
):
public function edit($id)
{
$user = User::find($id);
return View::make('userform')->with('user', $user);
}
Update:
Since the user id
is being selected dynamically from the select
so you have to use JavaScript
to set the form action
with id
and in this case, you may try following approach:
// Add this line before you submit the form
this.form.action = 'user/' + this.value;
// Now submit
this.form.submit();
Or using jQuery
you may try this:
$('#client_id').on('change', function(e){
var select = $(this), form = select.closest('form');
form.attr('action', 'user/' + select.val());
form.submit();
});
In this case, keep the form action
blank, use a blank string like url => ''
.