Nova Actions: default value (both with resource or "static value")
phlisg opened this issue · 2 comments
phlisg commented
Hello!
I'm using a lot of actions to update fields, as I'm developing a custom UI to improve some UX stuff. Alongside these actions, I use this package a lot to allow the user to browse multiple resources or static options (like "status").
In order to ease the UX for the users, I'd like to pre-fill the Multiselect field with the currently set value(s).
For example:
// File App\Nova\Actions\SomeAction
public function __construct(
protected Model $model
) {}
// "Static values":
public function fields()
{
return [
Multiselect::make('Canaux', 'channels')
->options(channels()->pluck('name', 'identifier')) // get all channels from db
->default($this->model->status),
];
}
// With async resources:
public function fields() {
return [
Multiselect::make('Utilisateurs', 'users')
->asyncResource(\App\Nova\User::class)
->default($this->model->users()->get()?->pluck('name, 'id')),
];
}
The MultiSelect
field from Nova supports default values but its UI/UX is limited for longer lists of objects.
Would it be possible to implement this, if it doesn't exist?
Thank you for your help :)
Tarpsvo commented
Heya! The defaults should work now for actions in version 4.3.0. :)
phlisg commented
And another great thanks :)