platform
platform copied to clipboard
Using Async Parameters in Modal rendering
Is your feature request related to a problem? Please describe. There is no possibility to get parameters that getting by async request in during specify modal layouts.
Describe the solution you'd like To have a method to get access to these params for more flexibility. Now we can get only access to result of query method.
Perhaps you're talking about this - https://orchid.software/en/docs/modals/#asynchronous-data-loading
In general everything is similar to the usual work with data in a Screen, only for the Screen the data is prepared in query
, and for the modal in the method indicated in ->async
and then this data can be accessed in modal layouts..
How could i decide the following problem:
In UserEditLayout i need to get access to User model that i get in asyncGetUser method to render layout depends on its state?
class UserListScreen extends Screen
{
public function query(): iterable
{
return [
'users' => User::with('roles')
->paginate(),
];
}
public function layout(): iterable
{
return [
UserFiltersLayout::class,
UserListLayout::class,
Layout::modal('asyncEditUserModal', UserEditLayout::class)
->async('asyncGetUser'),
];
}
public function asyncGetUser(User $user): iterable
{
return [
'user' => $user,
];
}
}
class UserEditLayout extends Rows
{
public function fields(): array
{
// need to access to User model
return [
];
}
}
I have the same question. The documentation shows how to pass a variable to a modal, but there is no clear example how to refer to the passed variable from within the modal layout.