Wednesday, February 4, 2009

Re: Validate belongsTo model in select element - inList does not seem to work?

On Wed, Feb 4, 2009 at 7:02 AM, grigri <jp@hendersonwebdesign.com> wrote:
>
> Something like this should work:
>
> (code not tested, but theory sound)
>
> class Customer extends AppModel {
> var $validate = array(
> 'country_id' => array(
> array(
> 'rule' => array('custom', '/^[a-z]{2}$/'),
> 'required' => true,
> 'message' => 'Please select the country that you reside in.'
> ),
> array(
> 'rule' => array('checkCountry'),
> 'message' => Please stop playing with firebug.'
> ),
> )
> );
>
> function checkCountry($data) {
> $countryCode = reset($data);
> return $this->Country->hasAny(array('Country.code' =>
> $countryCode));
> }
> }
>
> hth
> grigri

That's much more sound. And thanks for the laugh.

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