Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi ,
This problem occurs in a simple form.
$form['my_date'] = [
'#type' => 'date_popup',
'#title' => t('MyDate'),
'#required' => TRUE,
'#date_format' => 'Y-m-d',
'#date_label_position' => 'within',
'#date_year_range' => '-3:+3',
'#datepicker_options' => array(),
If in my form in the date value i put for example 2015-50-50 it should be tested if is a valid date value but instead i receive a notice
DateTime::format(): The DateTime object has not been correctly initialized by its constructor in DateObject->format() (line 392 of /var/www/html/sites/all/modules/date/date_api/date_api.module).
Ca anyone give me a quick fix ?
Comment | File | Size | Author |
---|---|---|---|
#8 | check_correct_date-2648114-8.patch | 545 bytes | tsapenkoum |
Comments
Comment #2
CaDyMaN CreditAttribution: CaDyMaN commentedWe can override the callback value function in element_info and check if the date value is correct or not.
Comment #3
Garmisch CreditAttribution: Garmisch commentedI have the same problem. Have you found a "quick fix"?
Comment #4
tsapenkoum CreditAttribution: tsapenkoum at Drupal Ukraine Community for Drupal Ukraine Community commentedComment #5
tsapenkoum CreditAttribution: tsapenkoum at Drupal Ukraine Community for Drupal Ukraine Community commentedI check correct date in function date_days_in_month
Comment #6
bohartAccording to https://www.drupal.org/coding-standards
1) We should use FALSE instead of false.
2) Else statement should be fixed according to CS.
Thanks!
Comment #7
tsapenkoum CreditAttribution: tsapenkoum at Drupal Ukraine Community for Drupal Ukraine Community commentedi fixed code to CS
Comment #8
tsapenkoum CreditAttribution: tsapenkoum at Drupal Ukraine Community for Drupal Ukraine Community commentedfile for prev comment
Comment #10
podarokThis is an API fix. Merged. Thanks.