premieroctet / next-admin

▲ Full-featured admin for Next.js and Prisma
https://next-admin.js.org
MIT License
324 stars 19 forks source link

[FEATURE] - Support nulling or clearing a related field #471

Closed minism closed 1 month ago

minism commented 1 month ago

Summary

For tables with nullable foreign keys, I am able to set the value in the edit view, but not clear it. Clicking the "X" next to the select input to clear it and saving the form results in the old value persisting. There doesn't seem to be a way to clear or set the field back to null - is this a missing feature?

Basic Example

I have two tables configured in prisma as so:

model users {
  id                       String                     @id
  email                    String?
  purchasable_packages     purchasable_packages[]
}

model purchasable_packages {
  id                 Int                 @id @default(autoincrement())
  num_requests       Int
  custom_for_user_id String?
  users              users?              @relation(fields: [custom_for_user_id], references: [id], onDelete: Cascade, onUpdate: NoAction)
}

custom_for_user_id is a nullable column, and so users is a nullable relation field.

Drawbacks

No response

Unresolved questions

No response

cregourd commented 1 month ago

Hi, thanks for your feedback. A patch is available on v6.1.6 🚀

Feel free to give us any other feedback