I get the following error after I try to populate a Date field in a Profile 2 profile

Notice: Undefined index: field_birthday in date_combo_validate() (line 334 of /date/date_elements.inc)
Notice: Undefined index: field_birthday in date_combo_validate() (line 335 of /date/date_elements.inc)

Settings:
- Not required.
- Default display: medium
- Default value: Blank.
- input format: 10/01/2011 - 16:06:52. (dd/mm/yy hh:mm:ss)
- Number of values: 1
- To date: Never
- Granularity: select Year, Month and Day
- No time zone conversion

CommentFileSizeAuthor
#11 10363144.patch1.13 KBalpritt

Comments

zarudnyi’s picture

I have the same error with clean Drupal install and default Date module settings.

wa2nlinux’s picture

Same error using profile 2 on date field
Granularity: select Year

das-peter’s picture

Looks like this error occurs if the date is used in a tree structure of form values.
Atm. I'm not sure what the two conditions on line 334 / 335 are for. But I hope to code below is an usable approach to iterate to the position of the field values:

  $item = &$form_state['values'];
  $posted = &$form_state['input'];
  foreach($element['#parents'] as $parent) {
    $item = &$item[$parent];
    $posted = &$posted[$parent];
  }
bvbunnik’s picture

Applied this code instead of the original lines (334 & 335 of date_elements.inc) and can confirm this is (for me) a working solution!
Thanks a lot for your effort!

aanjaneyam’s picture

#3 works for me too.

Anonymous’s picture

Same issue here also.

griz’s picture

I had a similar but different error referring to lines 334 and 335.
I then tried the patch in #3 - no beans.
Next I tried the dev, with and without the patch... Still no beans.
Then I downloaded a fresh copy of the dev and deleted my field and created another one with a different machine name.

Everything is green.

Moral of the story? Read the trouble-shooting guide.

mortona2k’s picture

Works, thanks!

arlinsandbulte’s picture

Status: Active » Postponed (maintainer needs more info)

So... is a patch needed?
Or is this fixed in -dev? (#7 is not clear about that)
Thanks

clauded’s picture

I have a similar issue with the latest dev modules but on different lines :
Notice: Undefined index: timezone dans date_field_validate() (ligne 311 dans var/www/drupal/sites/all/modules/date/date.field.inc).
Notice: Undefined index: value2 dans date_field_validate() (ligne 312 dans /var/www/drupal/sites/all/modules/date/date.field.inc).
Recreating the date filed after the updates don't work for me.

Sorry for the noise : issue with line 334 is gone with latest dev but now I have this : http://drupal.org/node/1021512#comment-4066984

alpritt’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new1.13 KB

Confirmed with Profile2. Also tested with the field attached to a node (which worked previously and continues to work with this patch).

Basically the same as #3 but using the helper function.

das-peter’s picture

Thanks alpritt - didn't even know such a nice function exists :)

sw3b’s picture

#11 work like a charm ! Thanks !

karens’s picture

Already saw #1021512: Errors when using Profile 2 with Date module, didn't see this issue. Looks that is unrelated to this one, just linking them in case.

karens’s picture

I avoided that function because it wasn't working right in some cases. This needs to be tested when using a complex date that uses a repeating date with a RRULE and a date-specific timezone and empty values in the 'To' date that need to be populated with values from the 'From' date to be sure that still works right.

karens’s picture

Status: Needs review » Fixed

There was another similar issue with a similar patch that I committed this morning. This should no longer be an issue.

Status: Fixed » Closed (fixed)

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