F
Filamentβ€’3mo ago
WessBechard

Error on creating record

foreach() argument must be of type array|object, string given When I create a record for my Organizations model, I'm getting this error, but no further details. The laravel log shows this additional information: production.ERROR: foreach() argument must be of type array|object, string given {"userId":3,"exception":"[object] (ErrorException(code: 0): foreach() argument must be of type array|object, string given at /var/www/html/portal/vendor/livewire/livewire/src/Mechanisms/HandleComponents/Synthesizers/CollectionSynth.php:28) I have two models that are behaving this way, and many others that are working without issue. I can't seem to figure out how to resolve the issue.
3 Replies
toeknee
toekneeβ€’3mo ago
Something is passing a string in opposed to an object or array. Go back and see how it works πŸ™‚
WessBechard
WessBechardβ€’3mo ago
In my form I have one hidden field for an ID, two selects, and the rest are just text. Is there no way to narrow down which it could be? Ok I figured it out, but it seems like either I'm doing it wrong, or it's a bug. Issue occurs when I try to set the default value for a Select. If I remove the default, it works. Forms\Components\Select::make('currency_type') ->options(['CAD', 'USD']) ->default('CAD') In that example, simply setting the default makes this very unhelpful error message show.
Dennis Koch
Dennis Kochβ€’3mo ago
Options should be key => value. So the default for CAD is 0
Want results from more Discord servers?
Add your server
More Posts