I'd rather do the following
{{ Form::button('Edit', array('type' => 'button', 'class' => 'btn btn-default btn-primary btn-switch', 'data-type' => 'edit')) }}
{{ Form::button('Add', array('type' => 'button', 'class' => 'btn btn-default btn-success btn-switch', 'data-type' => 'add')) }}
{{ Form::hidden('btnSelected', Input::old('btnSelected'), array('id' => 'btnSelected')) }}
You'll need some jQuery here, to populate the #btnSelected hidden input with the type of button selected.
$('.btn-switch').on('click', function(){
$('#btnSelected').empty().val($(this).attr('data-type'));
$('#yourForm').submit();
});
Now, how this works..
First off, you have the two buttons, but not submit, just plain ol' buttons. As you can see, I added the data-type attribute in order to detect what button was pressed.
After a button is pressed, the #btnSelected input is populated with this data-type attr I previously mentioned, and then the form submit() event is triggered.
From your controller, you'll just have to do
Input::get('btnSelected');
This will return you the type of button that was pressed.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community