Select createOptionForm not saved with the record
I have the following code which it works in v2 but not after upgrade to v3. The category saved and appeared in the select, but when save the form it's not saved with the created model.
7 Replies
I've got it the other way around, after creating it in the modal its not visible in the select but when saving its connected.
Can't find the reason. For now, I add the category_id to the Model $fillable until I have a time to dig it more
Without category_id in $fillable, do your category selections save if you are selecting an existing one rather than creating a new one?
Yes, the existing categories saved. The new one created and appeared in the select but not saved. You need to edit the record and re-select it. Also, I guess it will return errors if my category_id not nullable
And is global_id the primary key of the model?
No, it's not
OK, the createOptionUsing() method has to return the key of the created model, I guess it doesn't have to be the PK, although 99 times out of 100 it would be. But it needs to be whatever your Select relationship ('category') is using as the key.