spatie / blender

The Laravel template used for our CMS like projects
https://freek.dev/on-open-sourcing-blender
877 stars 148 forks source link

Tags method doesn't render multiple selected tags #390

Closed AlexVanderbist closed 7 years ago

AlexVanderbist commented 7 years ago

Adding the multiple attribute on the category <select> doesn't re-evaluate the selected values and thus only reders one <option> as selected. Setting the value again after the attribute was added triggers applyValueToOptions and renders multiple selected <option>s.

An alternative fix would be the following:

    public function tags(string $type): Select
    {
        $this->ensureModelIsAvailable();

        return $this->multiselect(
            "{$type}_tags[]",
            Tag::getWithType($type)->pluck('name', 'name'),
            $this->model->tagsWithType($type)->pluck('name', 'name')
        )
            ->attribute('data-select', 'tags');
    }
freekmurze commented 7 years ago

Thanks!