thedevdojo / voyager

Voyager - The Missing Laravel Admin
https://voyager.devdojo.com
MIT License
11.78k stars 2.67k forks source link

Select Multiple fields return exception on browse page #2207

Open neverfan opened 6 years ago

neverfan commented 6 years ago

Laravel Version: v5.4.36 Voyager Version: 1.0.7 PHP Version: 5.6.30 Database Driver & Version: PgSQL

Description:

On edit page for formfields "select_multiple" field value alway need being json: https://github.com/the-control-group/voyager/blob/master/resources/views/formfields/select_multiple.blade.php#L6 and convert it to object(stdClass), but when this field is output in browse view this field used as array: https://github.com/the-control-group/voyager/blob/master/resources/views/bread/browse.blade.php#L104

Whats wrong:

  1. Checking isArray(), but it's object(stdClass) and select not working. https://github.com/the-control-group/voyager/blob/master/resources/views/formfields/select_multiple.blade.php#L29
  2. Bad idea wait always json string and trying json_decode for it. It may be any type of data, for example PostgreArray: {value1,value2,...} and that not be work. Think any developer must decide how prepare field data to array and view templates alway need wait array.

Steps To Reproduce:

Open any bread browse page and output some field with select_multiple value.

The best solution in my opinion

Cancel this merge: https://github.com/the-control-group/voyager/pull/1818/files and return developers to prepare data how they need

Bloodlog commented 6 years ago

+1

neverfan commented 6 years ago

Looks some any one issue https://github.com/the-control-group/voyager/issues/1964

Bloodlog commented 6 years ago

If I have pgsql array I can't use multiple select for field becouse this filed waited json string, but in database field not valid json. I think this commit is mistake.