Thursday, October 2, 2008

Re: Help setting custom validation counting rule

Im doing this way, but it's not quite working:
In my model:

[code]
'state' => array(
'limit' => array(
'rule' => array ('limitState', 10),
'message' => '*The limit for this state has been
reached'
),

//Along with other rules...

//then the function:
function limitState($data, $limit) {
$count = $this->find('count', array('conditions' => $data,
'recursive' => -1) );
return $contagem < $limit;
}

[/code]

I think I just need to narrow my find to only the 'CA' state, but I dont
know how can I do that. Anyone know?

Thanks again!

mig_akira wrote:
>
> Hello!
>
> I need help making a custom validation rule here.
>
> I made a simple form, with name, adress, etc.
>
> But in the field 'State', I must limit the max number of people from a
> certain state. Let's say, there can be only 300 people from California
> submitting. THe other states have no limitation whatsoever. The data from
> state is stored in a varchar field, with only the 2 first letters of the
> state ('CA', for example). So I must count how many people from 'state' ->
> 'CA' there is and then must set up a custom rule that prevents people from
> submitting to the site when the max number's been reached.
>
> Thanks, any help will be appreciated!
>

--
View this message in context: http://www.nabble.com/Help-setting-custom-validation-counting-rule-tp19787584p19789495.html
Sent from the CakePHP mailing list archive at Nabble.com.


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