Relationship repeater not working
I'm creating a form where the users create a new
PlayerPreinscription
model.
This model has many PlayerTutorPreinscription
:
So a person can fill the form with multiple tutors (repeater) for a player.
if in the form i put this line, i get the error (see image), otherwise i dont get the error but the items in the repeater are ignored and not saved into the db.
->relationship('tutors')
other stuff i already do:
in mount method:
$this->playerPreinscription = new PlayerPreinscription;
i also defined the fn:
and in the save method i call save relationships:
i am missing something? what is happening? ive been strugling for quite a time now... hours9 Replies
Interesting.
ORDER BY 1
, sets it to order by the first column in the SELECT
(though its use is discouraged). ORDER BY `1` however is treating 1 as the name of a column.so it is a bug or im missing something π€ π’?
It seems like a bug, but I'm not familiar with the underlying code.
Your usecase is pretty simple and seems to fit with the documentation.
What happens if you explicitly set the
orderColumn()
on the repeater?yeah its just a filament form with some fields and a repeater field, which is a relationship. i tried to check everything out related on how to setup relationships & models in a filament form (v2). i think im not missing anything
1 sec i try
This is the code that builds that query: https://github.com/filamentphp/filament/blob/ac0e19b990f1f00a92cdd16f0c1987c50f0eb233/packages/forms/src/Components/Repeater.php#L1053
oh god
i think
1 sec still testing
i think ill make it reorderable false
cuz i dont have a order field in my db on that table!
i was missing that if i wanted to be reorderable
but if i remember well, on v3 i can reorder
i mean, without that db field
and it just reorders it lets say "in the frontend"
interesting im checking it out
Yeah, if you're reordering a relationship it needs a field it can update.
If you just use
reorderable()
, it defaults to setting orderColumn
to sort
true, and that col doesnt exist in my case (,:
now im trying to send the form lets see if it stores the relationship
lets go!!!!!!!
it works perfectly now
omg, thanks for enlightening me