I'm also new to cake and I just accomplished this myself a few days
ago. I only do the start before end validation and not end after
start. I don't know if that's a good way to do it or not. In the
startBeforeEnd validation you specify which field you want to compare
the 'start' field to, in my case it's 'end'. I included a "can't be in
the future" validation in case you might have use for that too.

Here is a portion of my model's code:

        var $validate = array(
                'start' => array(
                        'startBeforeEnd' => array(
                                'rule' => array('startBeforeEnd', 'end' ),
                                'message' => 'The start time must be before the 
end time.'),
                        'futureDate' => array(
                                'rule' => array('futureDate', 'start'),
                                'message' => 'The start time can not be in the 
future.'),
                ),
        );

        function startBeforeEnd( $field=array(), $compare_field=null ) {
                foreach( $field as $key => $value ){
                        $v1 = $value;
                        $v2 = $this->data[$this->name][ $compare_field ];
                        if($v1 > $v2) {
                                return FALSE;
                        } else {
                                continue;
                        }
                }
                return TRUE;
        }
    function futureDate($data, $field){
                if (strtotime($data[$field]) > time()){
                        return FALSE;
                }
                return TRUE;
    }
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to