Thursday, September 30, 2010

Manually set date field using a string "YYYY-MM-DD" does not work?

Hi everybody

Take a look at the following code:

$this->Contract->create($this-
>getValidDataExcept(array('date'))); // Creates a nearly valid
contract (only date is missing)
debug($this->Contract->field('date')); // (empty) - ok
debug($this->Contract->validates()); // 1
debug($this->Contract->field('date')); // 2009-09-24 - ok
$this->Contract->set('date', '2010-11-11');
debug($this->Contract->validates()); // 1
debug($this->Contract->field('date')); // 2009-09-24 - not ok!

Can't I set a date field manually using a string? And why does the
model validate and simply ignore my seemingly wrong date input value?
At least it should complain that date's value is not in a valid
format, shouldn't it?

Thanks for help
Josh

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

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: