-
Notifications
You must be signed in to change notification settings - Fork 917
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] Cannot remove value in repeatable #5778
Comments
Based on the information provided in the knowledge sources and your question, it appears you're encountering a bug related to removing values in a repeatable field using Backpack with the Pro addon. This issue is similar to problems reported in several GitHub issues for Backpack. The error you're experiencing seems to be related to how Backpack handles the deletion of related entries in a HasMany relationship. When you remove a user from the repeatable field and save, Backpack is trying to update the There are a couple of potential solutions you can try:
CRUD::addField([
'name' => 'users',
'type' => 'relationship',
// ... other attributes ...
'force_delete' => true,
]); This option was mentioned as a workaround in Github Issue #4204.
It's worth noting that the error message you're receiving suggests that the If these solutions don't resolve your issue, it would be advisable to report this as a new bug on the Backpack GitHub repository, as it might be a specific edge case not covered by existing fixes. ℹ️ Please note our AI Bot does not reply to follow-ups, this will be the only AI answer in this thread. If the AI helped you find the answer, please mark it as answered or write details below so it can learn. Then close the conversation. If not, please give more information for when a human reads this. ℹ️ Relevant sources: Fields|Using the table in a repeatable field |
Also, I noticed right now that the create inline operation button doesn't appear on my dealership crud controller, but on the user controller appear correctly, in the user controller I simply have defined as the following:
could I please get an help? |
Hello @cod3rshotout Did you try to add to the relationship
This work for you? Cheers. |
Hi @jcastroa87 yes I tried that option but if I set force_delete true, then the entry will be removed, I don't need this behavior. I need a repeater on the dealership controller that allows me to assign to that dealer a list of users. The association between user and dealers is done using the dealership_id column available on the user table. I don't have a pivot table since a user can only have one dealership associated. Also, the inline create button doesn't appear |
@pxpm @tabacitu @jcastroa87 please could I get a feedback about this issue? |
I'm using the latest backpack version with pro addon, this is my field:
essentially a dealership can have many users, but a user can only have one dealership.
This is the relationship on Dealership model:
and this is the relationship on User model:
When I save the users on the Dealership controller everything works fine, but when I remove one user from the repeatable and then save I get:
SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: 'NULL' for column
razor
.users
.dealership_id
at row 1 (Connection: mysql, SQL: updateusers
setdealership_id
= NULL,users
.updated_at
= 2025-02-20 12:42:47 whereid
not in (5) anddealership_id
= 1)The column dealership_id is set to nullable on the users table, I don't understand
The text was updated successfully, but these errors were encountered: