Friday, May 1, 2009

Re: Validate HABTM

Here you'll find the solution:
http://teknoid.wordpress.com/2008/10/16/how-to-validate-habtm-data/


On 1 Maj, 00:00, "Dave Maharaj :: WidePixels.com"
<d...@widepixels.com> wrote:
> I have tried figuring this out on my own to no avail.
>
> Where do I validate data being saved into a HABTM table? I have
> USERS:
> id
>
> SYSTEMS:
> id
> name
>
> USERS_SYSTEMS:
> id
> user_id
> system_id
>
> I created a simple form for the User to update their Systems but where is
> validation for this? Do I validate system_id in system model? Do I make a
> user_systems model and set a validation rule for system_id and user_id
> there? There is no system_id in the system model so it makes no sense to me
> to put it in there.  I made a user_systems model and put
> var $validate = array(
>   'system_id' => array('rule' => array('minLength', 8)) //min 8 just to
> check if it works as there are only single digit values in db
>  );
> but it still saves so I am at a loss....
>
> Can someone point out what model do I use to validate the HABTM data being
> saved to the HABTM table?
>
> thanks
>
> Dave
--~--~---------~--~----~------------~-------~--~----~
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 cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: