open-admin-org / open-admin

open-admin forked from z-song/laravel-ladmin. Removing jquery, now based on Bootstrap5, vanilla JS
https://open-admin.org
MIT License
255 stars 75 forks source link

multipleSelect does not work in Popup form - actions #190

Open Tech-Loyal opened 1 week ago

Tech-Loyal commented 1 week ago

Describe the bug When creating a list of multiple selections in the Popup form, RowActions shows an error (with 'select' it works).

To Reproduce Code of the actions `class SendWorkDetails extends RowAction { public $name = 'Send Work Details';

public $icon = 'icon-file-download';

public function form()
{
   $emails = SendEmail::where('status', 1)
        ->pluck('name', 'id')
        ->toArray();

    $this->multipleSelect('emails', 'Send emails')
        ->options($emails);
}

public function handle(Model $model, Request $request)
{
    $emailIds = (array) $request->get('emails');
    $emails = SendEmail::whereIn('id', $emailIds)
        ->pluck('email')
        ->toArray();

       $workDetails = [
        'alias' => $model->alias,
        'description' => $model->description,
        'date_start' => $model->date_start,
        'date_end' => $model->date_end,
        'responsible' => $model->responsible,
        'sede' => $model->sede->name,
        'area' => $model->area->name,
        'budget' => $model->budget,
        'observation' => $model->observation,
    ];

      foreach ($emails as $email) {
        Mail::to($email)->send(new WorkDetailsMail($workDetails));
    }

    return $this->response()->success('Exito!')->refresh();
}

}`

Screenshot_21

Expected behavior I need a multipleSelect to be displayed in the Popup form to select several emails System

Ladel commented 1 week ago

Сheck it out

public function form()
{
   $emails = SendEmail::where('status', 1)
        ->pluck('name', 'id')
        ->toArray();

    $this->addValues(); // add this

    $this->multipleSelect('emails', 'Send emails')
        ->options($emails);
}
Tech-Loyal commented 1 week ago

It's amazing how a line of code can solve so many things, thank you very much for the prompt response.