Wednesday, September 2, 2015

Re: Compare 2 date in cake3



Il giorno mercoledì 2 settembre 2015 02:24:34 UTC+2, Anthony GRASSIOT ha scritto:

'custom',['rule' =>  [$this, 'checkDate']]

this doesn't seems to be a correct syntax... Why don't you use one of the proposed solution ?

$value->gte raise errors ( is a query method); the strange think is that:
->add('end_date', [
            'valid'=> ['rule' => 'date'] ,
            'compare' => [
'rule' => function ($value, $context) {
$date_end = Time::createFromFormat('d/m/Y',$value);
$date_start = Time::createFromFormat('d/m/Y',$context['data']['start_date']);
                                                                                                                 // return ($date_start < $date_end); let's test!
return false;
                    }
                    ]
             ]
    
            );
            
as  you can see i return always false ( just for testing) but the rule doesn't work :(

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: