Thanks for the replies.

Aaron, could you please elaborate about the conditions in the
validation?

Regards,
Ariel

>
> w.r.t the hasMany relation, as long as you omit conditions from your
> validation and your SQL schema is set properly, you will not run into
> any problems.
> /a
>
> On Apr 21, 1:31 pm, Ariel Arjona <[EMAIL PROTECTED]> wrote:
>
> > Hello,
>
> > I seem to run often into the situation where I have a field certain
> > fields in my tables that are basically drop down lists, but they are
> > optional. I'm wondering what's the correct way to manage this.
>
> > Here's an example:
>
> > I have a User model and a Department model. Not every user has a
> > department (ie. contractors, temps). Right now the tables look like
> > this:
>
> > users:
> > id - int
> > department_id - int nullable
> > name - varchar
> > etc etc.
>
> > departments:
> > id - int
> > name - varchar
>
> > and the model associations are
> > User belongsTo Department
> > Department hasMany User
>
> > I'm wondering if this is the correct approach. Does hasMany expects a
> > value on the other side? are nullable FKs a bad practice? So far I've
> > run into some cosmetic weirdness in views. The next field folds into
> > the null field. Also I've had to add modify my views like so:
>
> > echo $form->input('department_id', array('options' => array('NULL'=>'-
> > None-') + $departments));
>
> > This still feels a bit clunky, but not as much as does setting it up
> > as HABTM. Is there an easier/more correct way?
>
> > Thanks in advance,
> > Ariel

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to