Field : field_date_1
Type : Date
Widget : Pop-up calendar
The settings for date field is as shown in 2 images
I get the values of a form_state into the $source_node and move that to $fs variable.The $source_node has date field stored as follows :
[field_pt_date_1] => Array
(
[und] => Array
(
[0] => Array
(
[value] => 2010-08-27 00:00:00
[timezone] => America/Phoenix
[timezone_db] => America/Phoenix
[date_type] => datetime
)
)
)
$fs['values']['field_date_1']['und'][0]['value'] = date('m/d/Y', strtotime($source_node->field_date_1['und'][0]['value']));
$fs['values']['field_date_1']['und'][0]['timezone'] = $source_node->field_date_1['und'][0]['timezone'];
$fs['values']['field_date_1']['und'][0]['timezone_db'] = $source_node->field_date_1['und'][0]['timezone_db'];
$fs['values']['field_date_1']['und'][0]['date_type'] = $source_node->field_date_1['und'][0]['date_type'];
......... The errors I am getting after executing the above code is as follows :
A valid date is required for date_1.
drupal_form_submit('form_id', $fs, $source_node);
$errors = form_get_errors();
And when checked the $errors variable I get
$errors = Array
(
[field_date_1][und][0][value] => A valid date is required for <em class="placeholder">date_1</em>.
)
date('m/d/Y', strtotime($source_node->field_date_1['und'][0]['value']));
why this conversion instead of the actual value ? – jonhattan Oct 4 at 7:38