A common way I handle things in Drupal is to create a CCK type, and then create a custom submit handler to perform logic on the CCK fields when the node is submitted. However, I have been unable to get the value when the CCK field type is a Date field because the array is structured differently.
Here I assign the portion of the $form array I want.
//This is in the submit handler
$fromDatePRE = array();
$fromDatePRE[] = $form['field_bill_start'][0]['value']['date'];
$fromDate = ['0']['#value']['#date'];
$fromDate is printing the first character “S” of Sat 8/21/2010 which is the value I want , but I want the whole value. I know this has something do with how I’m accessing the array but I can’t figure it out.
This is what I’m working with – I added a comment to the value I’m trying to access:
drupal_set_message('<pre>'. print_r($fromDatePRE, TRUE) .'</pre>');
Which Yiedls:
Array
(
[0] => Array
(
[#type] => textfield
[#default_value] => Sat, 08/21/2010
[#id] => edit-field-bill-start-0-value-datepicker-popup-0
[#size] => 20
[#maxlength] => 30
[#attributes] => Array
(
)
[#description] => Format: Sat, 08/21/2010
[#post] => Array
(
[title] => llllllllllllll
[menu] => Array
(
[link_title] =>
[parent] => Array
(
[hierarchical_select] => Array
(
[selects] => Array
(
[0] => primary-links:0
[1] => label_1
)
)
)
[weight] => 0
)
[hs_form_build_id] => hs_form_7bf97c3c59ba2a064d6e841ae405dd30
[changed] =>
[form_build_id] => form-1f928faaa990f3809da391165d51981a
[form_token] => 616f6e8a7bb9c4ffc2aec65174c0817d
[form_id] => billing_node_form
[log] =>
[pathauto_perform_alias] => 1
[print_display] => 1
[print_display_urllist] => 1
[print_mail_display] => 1
[print_mail_display_urllist] => 1
[print_pdf_display] => 1
[print_pdf_display_urllist] => 1
[field_bill_start] => Array
(
[0] => Array
(
[value] => Array
(
//This is the value I need
[date] => Sat, 08/21/2010
)
)
)
[field_bill_end] => Array
(
[0] => Array
(
[value] => Array
(
[date] => 08/25/2010
)
)
)
[name] => administrator
[date] =>
[status] => 1
[promote] => 1
[op] => Save
)
[#programmed] =>
[#tree] => 1
[#parents] => Array
(
[0] => field_bill_start
[1] => 0
[2] => value
[3] => date
)
[#array_parents] => Array
(
[0] => field_bill_start
[1] => 0
[2] => value
[3] => date
)
[#weight] => 0
[#processed] => 1
[#required] =>
[#input] => 1
[#autocomplete_path] =>
[#process] => Array
(
[0] => form_expand_ahah
)
[#name] => field_bill_start[0][value][date]
[#value] => Sat, 08/21/2010
[#needs_validation] => 1
[#defaults_loaded] => 1
[#sorted] => 1
)
)