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 ?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

CaDyMaN created an issue. See original summary.

CaDyMaN’s picture

We can override the callback value function in element_info and check if the date value is correct or not.

Garmisch’s picture

I have the same problem. Have you found a "quick fix"?

tsapenkoum’s picture

Assigned: Unassigned » tsapenkoum
tsapenkoum’s picture

I check correct date in function date_days_in_month

bohart’s picture

Status: Active » Needs work
Issue tags: +CodeSprintUA

According 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!

tsapenkoum’s picture

i fixed code to CS

tsapenkoum’s picture

file for prev comment

  • podarok committed 4e2ed49 on 7.x-2.x authored by tsapenkoum
    Issue #2648114 by tsapenkoum: DateTime::format(): The DateTime object...
podarok’s picture

Version: 7.x-2.9 » 7.x-2.x-dev
Status: Needs work » Fixed

This is an API fix. Merged. Thanks.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.