You could add getter/setter for that attribute to your model, where you explode/implode the db/form value respectively. Not sure, if activeListBox can handle multiple selections. If not, you can use listBox instead.
ActiveListBox supports the same as ListBox, which means it will accept a string for a single pre-selected value, or an array for multiple values.
You could always write an extension that handles the morphing of data between the model and [Active]ListBox.
Since it does allow an array of selected values, all you have to do is ensure that your model retrieves the data from the database as an array. Serializing the data into the database is likely the best way, as then you just need to serialize before save, and unserialize after save. Better than dealing with comma-separated values at least.
Why should serializing be better than a comma separated list? While the overhead generated by serialize/unserialize and explode/implode is probably pretty much the same, the letter is much more readable in DB. And also more language independent. There might be other clients working on the database coming from JAVA etc.
If they’re concerned about portability, they should look at json_encode/json_decode
There’s good arguments for all 3 options. Personally if I have multiple options that would be saved though, I typically would just have a supporting table w/ a many-many relation, as that is cleaner and more portable
I agree. Serializing an array and saving it in the db will require unserializing every time you use it. And for the purpose i use it it’s much more convenient to use a comma separated list and like Mike said it’s readable. Anyways i am going to just use the beforeSave and afterSave methods.