Sunday, August 2, 2009

Re: possible to do validation in not current model? where should I put validation??

Try this:

$this->Product->Size->set($this->data);

if ($this->Product->Size->validates())
{
...

On Fri, Jul 31, 2009 at 3:12 PM, leafchild<leafchild.book@gmail.com> wrote:
>
> For example
>
> There are 3 tables "categories", "products" and "sizes", and I'm
> working on product page (product.php, products_controller.php,
> product.ctp).
>
> The database looks like this.
> sizes:
> -----------------------
> |        id           |
> -----------------------
> | category_id   |
> | size_name    |
> ----------------------
>
> products:
> -----------------------
> |        id            |
> -----------------------
> | sku                |
> | category_id     |
> | product_name |
> | size_id           |
> ------------------------
>
> categories:
> ---------------------------
> |        id                |
> ---------------------------
> | category_name   |
> ---------------------------
>
> Product page can add/edit product:
> Before I save new product the page also can  add new size.
>
> I can verify a product data such as sku value from the model but I
> want to also make sure,
> user can add new size name if it's not exist in the system(not exist
> in size table).
>
> I want to put validation code in model.
>
> Should I put validation code in size.php or product.php
>
> Also if I want validate this then I have to pass category also.
> (same size name can be exist if it has different category id)
> How can I pass specific value to model so I can set vilification in
> mode and not controller?
>
> Or in this case I should just put code in controller?
>
>
> thanks
> >
>

--~--~---------~--~----~------------~-------~--~----~
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: