Skip to content

Execute php callback on Grid->addSelection() for multiple selection #1727

@mhuser

Description

@mhuser

First of all, I want to thank you for this great tool that is atk4/ui !
Since some time I have a question which I believe does not find answer in the documentation (but maybe I am just blinded).
Let's suppose we have two models User and Role and User hasMany Role.

  • It is quite straightforward to use \Atk4\Ui\Grid and addCondition to display a given Role and add a User.
  • Also we can almost out of the box display the Role list of a User and add one using the same method.

My question is : how to use $grid->addSelection() to mass-attribute a Role to a selected set of User ? (Which enable to use grid filtering and sorting)
In the demo there is a call to some javascript

$grid->menu->addItem('show selection')->on('click', new \Atk4\Ui\JsExpression(
    'alert("Selected: "+[])',
    [$sel->jsChecked()]
));

But I does not understand how to relies on a php callback instead that would receive the selected id list and perform some processing such at foreach the list and create the appropriate role lines or others.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions