Relationship in Form not saving on create action.

Grid::make()
->schema([
Forms\Components\Select::make('housing_id')
->relationship('housing', 'type')
->required(),
Forms\Components\Select::make('employment_id')
->relationship('employment', 'type')
->required(),
]),
Grid::make()
->schema([
Forms\Components\Select::make('housing_id')
->relationship('housing', 'type')
->required(),
Forms\Components\Select::make('employment_id')
->relationship('employment', 'type')
->required(),
]),
This is inside my form, When I create a new record - the options do populate and when I dd on the $data in the function "handleRecordCreation", the fields are occupied with valid IDs. However, when I press to create, the values don't save. But if I go back in and edit that record and select options again, they do save that time. I dont have any custom logic to handle the records (I only added handleRecordCreation as a test to check the data, then removed it again)
5 Replies
Jamie Cee
Jamie CeeOP13mo ago
Just cant seem to find why it doesn't save initially. I believe it had previously worked before I added nested fieldsets, then I reverted back to what I had just to check but now that doesn't work either Got a fix by manually taking over the data and creating a new item. But if I've defined the relations properly like above, it should work by default?
matin rajabi
matin rajabi11mo ago
i have same problem, do you succeed to fix it?
Jamie Cee
Jamie CeeOP11mo ago
I didnt sadly, I just had to manually handle the data
matin rajabi
matin rajabi11mo ago
my case the problem was because of $fillable items in my model, i forgot to add the column to $fillable. is that ok for you?
Jamie Cee
Jamie CeeOP11mo ago
Nah, that wasn't my issue
Want results from more Discord servers?
Add your server