-3

I am using PHP Laravel and Twig the php function has a parameter as the following:

function onItemApprove($id){
$data = post();
$item = Spot\Shipment\Models\Item::find($id);
....
$item->update();
}

the twig has the following code :

{{ form_ajax('onItemApprove') }}

I want to pass the parameter $id in the twig form_ajax

1 Answers1

0

You can add option something like this

{{ form_ajax('onItemApprove', { data: { id: <<some_id>> }}) }}

Inside Handler get it from post, not as a parameter

function onItemApprove(){
    $id = post('id');
}

if any doubt please comment.

Hardik Satasiya
  • 9,547
  • 3
  • 22
  • 40