F
Filament16mo ago
jop00

Select field not showing new created record using modal

When I create a new record using the create modal of a select field with this code I get this error Undefined property: stdClass::$:
)->createOptionUsing(function ($data) {
$newProducer = new Producer();
$newProducer->fill($data);
$newProducer->user_id = Auth::id();
$newProducer->save();
return $newProducer->id;
)->createOptionUsing(function ($data) {
$newProducer = new Producer();
$newProducer->fill($data);
$newProducer->user_id = Auth::id();
$newProducer->save();
return $newProducer->id;
7 Replies
jop00
jop00OP16mo ago
It's a belongsToMany relationship
toeknee
toeknee16mo ago
try return $newProducer;
jop00
jop00OP16mo ago
with this I don't get the error but the select field is not filled with the new record do I need to send a dispatch event to upload the form?
toeknee
toeknee16mo ago
That is strange What if you remove the cerationOptionUsing() and let it create it from the relationshio
jop00
jop00OP16mo ago
If I remove the creationOptionUsing(): Undefined property: stdClass::$
toeknee
toeknee16mo ago
if you dd($newProducer) what do you get?
jop00
jop00OP16mo ago
I get the model Producer I updated the code and now it's working:
Select::make('producers')
->relationship('producers')
...
Select::make('producers')
->relationship('producers')
...
Select::make('producers') ->relationship('producers', 'name')
...
Select::make('producers') ->relationship('producers', 'name')
...

Did you find this page helpful?