Compare two pieces of date_popup fapi code, which give different results:

First the date_popup:

$form['check_in_date'] = array(
	'#type' => 'date_popup',
	'#title' => t("Check-in Time"),
        '#date_format' => 'm/d/Y h:i a',	
);

Then, two flavors of submit button, try each independently:

$form['check_in_date_submit'] = array(
   '#type' => 'submit',
   '#name' => 'check_in_date_submit',
   '#value' => 'Check-In',
   '#ajax' => array(
       'callback' => '__check_in_ajax_submit',
    )
);

vs.

$form['check_in_date_submit'] = array(
	'#type' => 'button',
	'#name' => 'check_in_date_submit',
	'#value' => 'Check-In',
	'#ajax' => array(
	    'callback' => '__check_in_ajax_submit',
         )
);

then a basic submit handler like:

function __check_in_ajax_submit($form, &$form_state){
drupal_debug($form_state['values']);
//or, if you prefer:
dpm($form_state['values']);
}

top submit ('submit' type) of code results in $form_state['values']['check_in_date'] containing a date time string, as expected. The second submit ('button' type), however, results in an array containing only the key 'time', with no date. If I change the date format of the popup to "Y-m-d", it submits the date. Any other date format with a time involved ("Y-m-d H:i:s", for example) results in only the time being submitted, with no date.

Comments

CaptShmo created an issue. See original summary.

CaptShmo’s picture

Issue summary: View changes
CaptShmo’s picture

Issue summary: View changes