To simplify, I have companies and workers attached to them in my pyrocms app. In the companies (created by the table builder in the admin panel automatically), there are buttons in the raw of each company. edit button is one of them provided out of the box. So I want to add another button, say 'Add Worker', and open the page of worker creation which I have done successfully. There is a multiple relation between companies and workers since a worker can work in multiple companies. You can think it as a categories of any post. The thing I want is, in the worker creation form page, I want to have the company whose 'Add worker' button is clicked appear in the 'working companies' field of worker automatically. What is the proper way of implementing such idea? I can pass HTML attributes to button using attributes but I don't know if it helps.
This is the $buttons array in the CompanyTableBuilder.
/**
* The table buttons.
* @var array|string
*/
protected $buttons = [
'edit',
'add_worker' => [
'attributes' => [
'href' => '/admin/crm/workers/create',
],
'text' => 'Add worker',
'type' => 'success',
]
];
Let's imagine you have two groups of clients: workers and payers
When you would press the jobs button, you will go to
admin/{addon}/clients/jobs/{user_id}route. So you would need to have the next one controller:Then a value TB looks like:
then th valuetablebuttons:
And the same shit for the lookup TB:
And lookup TB buttons:
After that you would need only to write some JS for right behavior.
UPD: This is the example of *Query class:
And the example of AttachJobToUser command: