Hi,
I am using drupal_extectue to add nodes. When i try to add a date field i am getting validation error. i am using date popup and format 'YYYY-MM-DD'
I tried the following
$form_state['values']['field_termstartdate'][0]['value'] = "YYYY-MM-DDTHH:MM:SS";
$form_state['values']['field_termstartdate'][0]['value'] = "YYYY-MM-DD";
i got the error
"There are errors in Term Start Date:
* The dates are invalid.
"
$form_state['values']['field_termstartdate'][0]['value']['date'] = "YYYY-MM-DD";
$form_state['values']['field_termstartdate'][0]['value']['time'] = "HH:MM:SS";
i got the error
warning: mysqli_real_escape_string() expects parameter 2 to be string, array given in /includes/database.mysqli.inc on line 323
Thank you
Deepak
Comments
Comment #1
Anonymous (not verified) commentedI've tried both of the above methods and I'm getting the same errors. I'm also using Date Popup.
When I tried:
I got the error:
When I tried
I got these errors:
When I tried assigning a timestamp:
I got the error:
It seems like form.inc expects $form_state['values']['field_termstartdate'][0]['value'] to be an array, while date_token.inc and database.mysqli.inc expect it to be a string. Assigning a timestamp results in incorrect date values, so I'm using the second method (assigning ['date'] and ['time'] individually).
Thanks.
Update: None of these methods produce consistent, reliable results. I'm afraid I'm going to have to dump my date values into a CCK Textfield instead of a CCK Date field.
Comment #2
dariogcode commentedI'm not sure if this is the same, but I also experimenting this issue in D7, and same errors (Using in a res server request to another Drupal with D7).
I fixed this with a parameter all_day (Curiously this should be in same level than 'date', but module take this from the parent level
Note that 'und' is for D7, I think D6 may be similar
I hope this help you don't spend hours like me debugging.
Comment #3
notzach commentedI've been working on this with Drupal 6 most of the afternoon, apparently you have to format the date the same way that it is formatted in the widget on the node form. This worked for me:
You would do the same structure for your
value2key. I hope this helps someone figure this out.Comment #4
karens commentedThat's the way drupal_execute works, you have to mimic exactly the form element. That's why it's hard to use drupal_execute and I recommend node_save() where you don't have to know how the form is constructed.