I try to make a button/link which links to another backend list with some custom filter settings.
So: There’s Model A and Model B and the list of Model B can be filtered if it’s related to a certain entry of Model A. So there’s an ID filter for Model A in the Model B list.
Now I would like to create a button/link in the list of Model A, which redirect to the list of Model B with the filter setup to the corresponding ID.
So far, I tryed to do this with the Data Handler API:
<a data-request="onChangeBackendView" data-request-data="id:<?= $record->id; ?>">
Within this Handler, I retreived the ID from the send data and tried to forward to the list of Model B with the parameters for the filters, but I had no success this way.
public function onChangeBackendView()
{
$id = Input::get('id');
$parameters = [
'scopeName' => 'modela_id',
'Filter[condition]' => "equals",
'Filter[value]' => "123",
];
return Redirect::to(Backend::url('mch/modela/modelacontroller'))->withInput($parameters);
}
It didnt work out this way, so I tried to handle this directly via Data Handler API:
<a
data-request="onChangeBackendView"
data-request-data="scopeName:'modela_id', Filter[condition]:'equals', Filter[value]:<?= $record->id; ?>"
data-request-url="/backend/mch/modelb/modelbcontroller"
data-request-redirect="/backend/mch/modelb/modelbcontroller"
>
I guess the data-request attribute isnt optional since the link didnt work without it. I tried to pass the parameters which is send from the filters directly to the list of model B, but it also didnt work out.
So my question is: What’s wrong with my approaches? I guess I missed out a few things.
In case you see some issues with naming handlers or urls: I renamed a lot of stuff for this thread so it’s easier to understand which controller / handler I tried to call. I didnt have any problems with the forwarding / reaching a handler within my tests. Just the parameters for the filter were not applied.
Any help is welcome, thanks a lot. ^^