Posted by matt2000 on June 2, 2009 at 10:56pm
Jump to:
| Project: | Comment CCK |
| Version: | 6.x-1.0-beta2 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
When I update a Date field via comment cck, the field value is deleted instead of being updates to the new value.
Comments
#1
Bump!
I have the same problem. I wonder what other content types it deletes?
Nash
#2
this might be related to http://drupal.org/node/527258 please test.
#3
#4
The patch had no effect on the problem. The following was the error generated when a date was either modified or left unmodified. Please also note that the date field was submitted with a null value, which is why this error occurred:
* warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /var/www-track-dev.tools/public_html/sites/all/modules/date/date/date_elements.inc on line 550.
* warning: date_format() expects parameter 1 to be DateTime, null given in /var/www-track-dev.tools/public_html/sites/all/modules/date/date/date.theme on line 224.
* warning: date_format() expects parameter 1 to be DateTime, null given in /var/www-track-dev.tools/public_html/sites/all/modules/date/date/date.theme on line 225.
* warning: date_format() expects parameter 1 to be DateTime, null given in /var/www-track-dev.tools/public_html/sites/all/modules/date/date_api.module on line 733.
Your thoughts?
Nash
#5
After much playing around I figured this out. Basically when Comment_CCK data gets passed to all the various widget validation routines etc, each fields data exists in $form_state['comments_cck'][FIELDNAME]. The date_combo_validation route expects it to be in $form_state[FIELDNAME] and due to it not being there, the initial value of a flag never gets changed so it ends up replacing the $element['#value'] values with empty values.... if you didn't understand that don't worry, it made my head hurt too.
I hard coded a hack for this, unfortunately I'm new to Drupal and don't know enough about the data structures to fix it properly.
Find your copy of date/date/date_elements.inc and find function date_combo_validate (line 384 for me) and at the top of the function change
$form_values = $form_state['values'];
to
$form_values = $form_state['values'];
if ($element['#parents'][0] == "comment_cck")
$form_values = $form_state['values']['comment_cck'];
Repeat the changes in date_widget_validate (line 550 for me).
I'm thinking that you could probably check all values of $element['#parents'] starting at 0 (ending just before you get to the FIELDNAME entry) and use those to navigate the $form_state array, but I'm not too sure.
#6
LOL! Russell you are a genius! (He's only been playing around with drupal for about less than a day or so and came up with this hack!) ("...it made my head hurt too." - Yea right!)
#7
subscribe... i didn't get that and now my head hurts, too