I'm trying to call a controller method from a form object, to increment a given item.
The problem is that when adding the parameter, the form action will add a question mark, instead of a slash.
<form method="POST" action="http://localhost/admin/pages?1">
How am I to define the parameter?
{!! Form::open([
'action'=>['Admin\\PagesController@increment', $item->id],
'style' => 'display:inline'
]) !!}
{!! Form::submit('Move Up', ['class' => 'btn btn-danger btn-xs']) !!}
{!! Form::close() !!}
In you code sample, you are sending the item id as a HTTP GET parameter. You can access the item id in your controller by giving a name to the parameter as follows.
{!! Form::open([
'action'=>['Admin\\PagesController@increment','itemId='.$item->id],
'style' => 'display:inline'
]) !!}
Then access the item id in your controller by
Input:get('itemId')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With