Repeater acts differently when used inside createOptionForm
Hello everyone, so here's the situation - I have a ComparisonTableResource which basically lets the user build comparison tables on the frontent and includes a list of Operators (a different model) and lets the user change their order in such way -
It works just fine and behaves as expected, including saving the correct order inside the pivot table between
Operator
and ComparisonTable
(comparison_table_operator
).
Now, I have a different model and a resource called Lander
in which the user can choose an existing comparison table or create a new one, like this (in LanderResource.php
) -
Now, when simply selecting an existing comparison table - it works just fine, but when creating a new one and selecting the operators in the modal form, i get an error. saying SQLSTATE[HY000]: General error: 1364 Field 'name' doesn't have a default value
.7 Replies
The error then followed by this line -
Like its trying to insert a new operator?.. but why?
Due to character limitations, here are the full resources for a better understanding -
And here's the resource for
Lander
Anyone, please?On my phone, so having trouble reasoning all the code, but I’m wondering if it has something to do with the repeater having the same name as the relationship.
nope.. tried renaming it with no success.
the weird thing is that its working on the ComparisonTableResource as is (with the same name for both repeater as the relationship), but when used inside a modal with
createOptionFrom
it tries to insert new Operator
entries for some reason..
also, for some reason, the repeater order is only being saved when a new entry is created .. when im editing an existing ComparisonTable
and simply change the order of the Operators - it doesn't update it at all. Here's my CreateComparisonTable.php
file to handle the custom order -
I tried to mimic the same behvaiour in EditComparisonTable.php inside the handleRecordUpdate()
function, with no success.
any idea, @awcodes ?
I hava a comparison_table_operator
pivot table which simply should hold table ids, operators ids and their order in those tables, like this -
when i tried to simply dd($data)
inside the mutateFormDataBeforeSave
function - i noticed that the repeater fields array wasn't even there.Do you have a repo you could share. I would need to step through it to see what is happening.
sadly not atm. its a private repo.. is there any additional info i can provide or drop some dd()s here n' there?
I’m on my phone at the moment so it’s really difficult to follow all the code.
ok, thanks for your time and effort..