N
N
Nikita Zelikov2021-09-23 19:51:17
Laravel
Nikita Zelikov, 2021-09-23 19:51:17

Multiselect in sleepingOWL, how to implement?

I'm solving a problem related to slipping, I can't figure out how to solve it at the moment...
614caff58943c158269995.png
When choosing values ​​in the select, they form an array 614cb01ee54d3640682788.png
. I need to select several options and duplicate the insert query with values ​​of the second order, third order, etc.
Technically, I can do it in cycles, but where do these values ​​fall, where to accept them ...
Maybe someone fumbles for an owl and can suggest a way out?
tabs:

// Связь с фильтрами
            $filters = Filter::query()->oldest('order')->get();
            $filterValues = FilterValue::all()->groupBy('filter_id');

            $filtersElements = [
                '<h4 class="subform_header">Фильтры</h4>',
            ];
            foreach ($filters as $filter) {
                /** @var Collection $currentFilterValues */
                $currentFilterValues = $filterValues->get($filter->id);
                $options = $currentFilterValues->map(static function (FilterValue $item) {
                    return [
                        'id' => $item->id,
                        'value' => $item->name,
                    ];
                })->pluck('value', 'id')->toArray();

                $filtersElements[] = AdminFormElement::multiselect('params->' . $filter->id, $filter->name)
                    ->setOptions($options);
            }

            $filtersForms = AdminForm::elements([
                '<p>После изменения функционала надо обязательно сохранить изменения в базу (кнопка Сохранить внизу формы).</p>',
                AdminFormElement::hasMany('filters', $filtersElements),
            ]);
            $tabs->appendTab($filtersForms, 'Варианты фильтров', false);
        }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question