Laravel-admin: can not get selected option in Multipleselect in many to many relation

Created on 15 Apr 2018  ·  4Comments  ·  Source: z-song/laravel-admin

  • Laravel Version: 5.5
  • PHP Version: 7
  • Laravel-admin: 1.5.*

Description:

first of all, thanks for this awesome package

i can't get selected values tags in edit article

my form() method like
$form->multipleSelect('tags', 'Tags')->options(Tag::all()->pluck('name', 'id'));

and in Article Model, the relation method like
public function tags(){ return $this->belongsToMany('App\Tag')->select('id','name')->withTimestamps(); }

when i press edit button for any article, some fields working fine like 'title', 'description' but input tags field doesn't show selected tags for this article, just show all tags which come from Tag::all(), the input tags selected empty

how i can solve this proplem?

some screenshots

1

2

3

Most helpful comment

I had problems similar problems. I moved to explicit declaration and it works. Like so:

$form
    ->multipleSelect('tags', 'Tags')
    ->ajax('/api/list/tags')
    ->options(function() { return $this->tags->pluck('name', 'id'); });

All 4 comments

I had problems similar problems. I moved to explicit declaration and it works. Like so:

$form
    ->multipleSelect('tags', 'Tags')
    ->ajax('/api/list/tags')
    ->options(function() { return $this->tags->pluck('name', 'id'); });

I have this exact same problem.

Fix in #2479

I have this exact same problem.
Laravel Version: 5.7
PHP Version: 7.2

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zhenyangze picture zhenyangze  ·  3Comments

benny-sun picture benny-sun  ·  3Comments

cdhraesaemer picture cdhraesaemer  ·  3Comments

donglianyou picture donglianyou  ·  3Comments

wangwenfan picture wangwenfan  ·  3Comments