This seems like such a basic problem that I feel that I must be missing something. In my application, Managers are related m-to-m to Departments. A Manager has a private member $_deptsInput that is used with getDepts() and setDepts() to maintain an array() of depts in the Manager model. When the getter is called, if $_deptsInput is not an array, it is looked up in the database. $_deptsInput is used with an activeListbox to select Departments on the Managers form.
Everything works fine except when a Manager with Departments has all of them removed on the Manager form. The activeListbox submits nothing for the depts attribute. So when the getter is called, it sees that the value has never been set (even though the POST has set other attributes – and would set depts if one or more were selected). The getter looks depts up in the database, supplying the old array of depts, while the rest of the Manager model has the POSTed values in the model. This is only an issue when depts are entirely removed.
Any ideas what the correct solution is?