MonstreX / voyager-extension

Laravel: Voyager Extension
Other
71 stars 28 forks source link

Multi Select Edit json_decode(): Argument #1 ($json) must be of type string, array given #48

Closed BenWallmeyer closed 2 years ago

BenWallmeyer commented 2 years ago

i use voyager-extension 0.95.2

If i add Multiselect and add some Option like this { "default": "", "options": { "monday": "Montag", "tuesday": "Dienstag", "wednesday": "Mittwoch", "thursday": "Donnerstag", "friday": "Freitag", "saturday": "Samstag", "sunday": "Sonntag" } }

save add a new entry and than edit json_decode(): Argument #1 ($json) must be of type string, array given comes. If i use legacy Mode for Edit it will work.

This is already solved in https://github.com/the-control-group/voyager/issues/2207

MonstreX commented 2 years ago

I found only one way to fix it. You can do it on your own. 1) Copy original view select_multiple.blade.php from voyager into the folder inside app view -> /resources/views/vendor/voyager/formfields/select_multiple.blade.php 2) Make the fix - change one line. replace:

$dataTypeContent->{$row->field} = json_decode($dataTypeContent->{$row->field})

with:

$dataTypeContent->{$row->field} =  is_array($dataTypeContent->{$row->field})?
                  $dataTypeContent->{$row->field} :
                  json_decode($dataTypeContent->{$row->field});
BenWallmeyer commented 2 years ago

Work with update

BenWallmeyer commented 1 year ago

I tried have also latest laravel version and also test to isntall latest voyager version this is also not a problem but if I installed the latest voyager-extension there are a lot of dependencies which must be solved before.

Von: Yuriy Ovdeyev @.> Gesendet: Donnerstag, 8. September 2022 18:07 An: MonstreX/voyager-extension @.> Cc: BenWallmeyer @.>; Author @.> Betreff: Re: [MonstreX/voyager-extension] Multi Select Edit json_decode(): Argument #1 ($json) must be of type string, array given (Issue #48)

I've just checked it out. It works. I used the latest versions laravel, voyager, and voyager-extension.

— Reply to this email directly, view it on GitHubhttps://github.com/MonstreX/voyager-extension/issues/48#issuecomment-1240923382, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACBKBQCOL6A43FS7H6HYEJDV5IFLFANCNFSM6AAAAAAQG3JRQY. You are receiving this because you authored the thread.Message ID: @.**@.>>