Note that there are some explanatory texts on larger screens.

plurals
  1. POOnly getting the first character when accessing post variable
    text
    copied!<p>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.</p> <p>UPDATE - João Guilherme had a much simpler approach, but I still couldn't get the date value out of the array posted below.</p> <pre><code>$fromDate = $form['field_bill_start'][0]['#value']; drupal_set_message('&lt;pre&gt;'. print_r($fromDate, TRUE) .'&lt;/pre&gt;'); //Which then prints this. Array ( [value] =&gt; Array ( [date] =&gt; Tue, 08/24/2010 ) ) </code></pre> <p>I then tried adding these which printed null. I also tried the "#" before date and value.</p> <pre><code>['value']['date'] </code></pre> <p>*************************Original Post**********************************</p> <pre><code>&lt;?php function billing_form_billing_node_form_alter(&amp;$form, &amp;$form_state) { //drupal_set_message('We are hooking it!'); $form['#submit'][] = 'billing_submit_function'; } function billing_submit_function($form, &amp;$form_state) { $fromDatePRE = array(); $fromDatePRE[] = $form['field_bill_start'][0]['value']['date']; $fromDate[] = $fromDatePRE[0]['#value']['#date']; drupal_set_message('&lt;pre&gt;'. print_r($fromDatePRE[0], TRUE) .'&lt;/pre&gt;'); drupal_set_message("From Date = ".$fromDate[0]); drupal_set_message("From Date2 = ".$fromDatePRE[0]); </code></pre> <p><b> $fromDate is printing the first character "S" of Sat 8/21/2010 which is the value I want </b>, 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.</p> <p>This is what I'm working with - I added a comment to the value I'm trying to access:</p> <p>Which Yiedls:</p> <pre><code> Array ( [0] =&gt; Array ( [#type] =&gt; textfield [#default_value] =&gt; Sat, 08/21/2010 [#id] =&gt; edit-field-bill-start-0-value-datepicker-popup-0 [#size] =&gt; 20 [#maxlength] =&gt; 30 [#attributes] =&gt; Array ( ) [#description] =&gt; Format: Sat, 08/21/2010 [#post] =&gt; Array ( [title] =&gt; llllllllllllll [menu] =&gt; Array ( [link_title] =&gt; [parent] =&gt; Array ( [hierarchical_select] =&gt; Array ( [selects] =&gt; Array ( [0] =&gt; primary-links:0 [1] =&gt; label_1 ) ) ) [weight] =&gt; 0 ) [hs_form_build_id] =&gt; hs_form_7bf97c3c59ba2a064d6e841ae405dd30 [changed] =&gt; [form_build_id] =&gt; form-1f928faaa990f3809da391165d51981a [form_token] =&gt; 616f6e8a7bb9c4ffc2aec65174c0817d [form_id] =&gt; billing_node_form [log] =&gt; [pathauto_perform_alias] =&gt; 1 [print_display] =&gt; 1 [print_display_urllist] =&gt; 1 [print_mail_display] =&gt; 1 [print_mail_display_urllist] =&gt; 1 [print_pdf_display] =&gt; 1 [print_pdf_display_urllist] =&gt; 1 [field_bill_start] =&gt; Array ( [0] =&gt; Array ( [value] =&gt; Array ( //This is the value I need [date] =&gt; Sat, 08/21/2010 ) ) ) [field_bill_end] =&gt; Array ( [0] =&gt; Array ( [value] =&gt; Array ( [date] =&gt; 08/25/2010 ) ) ) [name] =&gt; administrator [date] =&gt; [status] =&gt; 1 [promote] =&gt; 1 [op] =&gt; Save ) [#programmed] =&gt; [#tree] =&gt; 1 [#parents] =&gt; Array ( [0] =&gt; field_bill_start [1] =&gt; 0 [2] =&gt; value [3] =&gt; date ) [#array_parents] =&gt; Array ( [0] =&gt; field_bill_start [1] =&gt; 0 [2] =&gt; value [3] =&gt; date ) [#weight] =&gt; 0 [#processed] =&gt; 1 [#required] =&gt; [#input] =&gt; 1 [#autocomplete_path] =&gt; [#process] =&gt; Array ( [0] =&gt; form_expand_ahah ) [#name] =&gt; field_bill_start[0][value][date] [#value] =&gt; Sat, 08/21/2010 [#needs_validation] =&gt; 1 [#defaults_loaded] =&gt; 1 [#sorted] =&gt; 1 ) ) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload