Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1024167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:44:20+00:00 2026-05-16T11:44:20+00:00

A common way I handle things in Drupal is to create a CCK type,

  • 0

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.

UPDATE – João Guilherme had a much simpler approach, but I still couldn’t get the date value out of the array posted below.

$fromDate = $form['field_bill_start'][0]['#value'];
drupal_set_message('<pre>'. print_r($fromDate, TRUE) .'</pre>');

//Which then prints this.
Array
(
    [value] => Array
        (
            [date] => Tue, 08/24/2010
        )

)

I then tried adding these which printed null. I also tried the “#” before date and value.

['value']['date']

*************************Original Post**********************************

<?php
 function billing_form_billing_node_form_alter(&$form, &$form_state) {
  //drupal_set_message('We are hooking it!');
  $form['#submit'][] = 'billing_submit_function';
}

function billing_submit_function($form, &$form_state) {
  $fromDatePRE = array();
  $fromDatePRE[] =  $form['field_bill_start'][0]['value']['date'];
  $fromDate[] = $fromDatePRE[0]['#value']['#date'];

  drupal_set_message('<pre>'. print_r($fromDatePRE[0], TRUE) .'</pre>');


  drupal_set_message("From Date = ".$fromDate[0]);
  drupal_set_message("From Date2 = ".$fromDatePRE[0]);

$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:

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
            )

    )
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T11:44:21+00:00Added an answer on May 16, 2026 at 11:44 am

    You should use the value submitted by the user which is on the $form_state;

    I tested with a single date field, instead of a datefield with 2 values. But this should work just fine anyways. I might have the naming of your field incorrect, but you can check out the values on $form_state['values'], where you should find your field listed.

    Anyways the code would look something like this:

    function billing_submit_function($form, &$form_state) {
      $from_date =  $form_state['values']['field_bill_start'][0]['value'];
      $from_date_string = format_date(strtotime($from_date), 'custom', 'D d/m/Y');
      $from_date_2 =  $form_state['values']['field_bill_start'][0]['value2'];
      $from_date_string_2 = format_date(strtotime($from_date_2), 'custom', 'D d/m/Y');
    
      drupal_set_message("From Date = ".$from_date_string);
      drupal_set_message("From Date2 = ".$from_date_string_2);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can somebody explain the common way to handle C2DM intents work? I have an
Is there a standard or common way in C++ to handle static strings that
What is the common way (or best practice) to optionally use JNI? E.g. I
What is the common way of dealing with the development.sqlite3 files with VCS (in
Whats the most common way of instantiating VB6 ActiveX controls inside of an Tcl/Tk
Is there a standard/common way to give compiler-style error messages that point to a
Is there a common way of counting source lines of code (SLOC) in a
I was wondering, what is the common way to log exception, if message is
What's the most common/best way to setup a WCF service project and applications? Here's
I want to learn a common and right way of calculation of height for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.