I'm not sure that I understand your question. But you can call the
model's function directly from the controller.

On Fri, Aug 7, 2009 at 4:42 PM, leafchild<leafchild.b...@gmail.com> wrote:
>
> Thanks, brian. but can I associate with my validation macadamized
> function?
>
> so if set validation in Size model:
>
> =====================================================
> ...
>                'size_name' => array(
>                        'namechk'=>array(
>                                'rule'=>array('namechk'),
>                                'message'=> 'Please enter different name.'
>                        )
> ...
>
> ...
>        function namechk($size_name){
>             /* want to check if size_name exist with same category_id
> here
>                If there is same size_name but different category id
> then it's ok */
>
>        }
> =====================================================
>
>
> Thanks,
> leaf child
>
>
>
> On Aug 4, 5:15 am, brian <bally.z...@gmail.com> wrote:
>> Create some method in the Size model and pass the category_id to it:
>>
>> if ($this->Product->Size->yourMethod($category_id))
>>
>>
>>
>> On Mon, Aug 3, 2009 at 3:45 PM,leafchild<leafchild.b...@gmail.com> wrote:
>>
>> > thanks brian.
>>
>> > Is possible to pass specific value to validation at model("Size" model
>> > in this case)
>>
>> > I want to create custom validation but I need to pass value to do it.
>> > (in this case, "category_id")
>>
>> > thanks,
>> >leafchild
>>
>> > On Aug 2, 8:49 am, brian <bally.z...@gmail.com> wrote:
>> >> Try this:
>>
>> >> $this->Product->Size->set($this->data);
>>
>> >> if ($this->Product->Size->validates())
>> >> {
>> >>     ...
>>
>> >> On Fri, Jul 31, 2009 at 3:12 PM,leafchild<leafchild.b...@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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to