I have a table called "users", and each user can belong to one group, described in a table called "categories". An example of use is “Alice belongs to the red category” and “Bob belongs to the category“ Blue ”, etc.
I use the CakePHP form helper, and on the page http: // localhost / users / edit / [user_id] he made a drop-down list to select a category (using JOIN in the model to get category names).
But I want to add an option to select NULL, because not all users must be part of a category. Adding a NULL entry to the category table will not work because the foreign key in the users table is category_id. I want "category_id" for a user who did not select a category as NULL, and not 1, which in another table is NULL.
Sorry if this was a little incoherent. Hope someone can follow him enough to tell me if there is a way for cakePHP, or should I come up with another way to do this.
Danny source
share