0

in my custom module, I have used the following code:

$form['event_date'] = array(
    '#type' => 'date_popup',
    '#title' => 'Set Date & Time :',
    '#date_format' => 'd-m-y H:i',
    '#default_value' => date('d-m-y H:i'),
    '#date_year_range' => '-3:+3',
    );

but after submitting it only show time field value. also work fine when only use date('d-m-y').

screenshot

1
  • What is in $form_state['values']['event_date'] both in the validation and submit handlers? The names in your two screenshots don't match up.
    – mpdonadio
    Commented May 1, 2014 at 1:42

2 Answers 2

0

Yep, I found it in $form_state['input'].

I am actually using this with Ajax. so In callback function you can get the form values from $form_state array. All form values are present in $form_state['values'] and input type values are also can be found in $form_state['input'].

2
  • 1
    Could you please try to edit this answer so it would be usable for future readers?
    – Mołot
    Commented Apr 23, 2014 at 9:23
  • 1
    Currently it is not understandable, please explain brief, we accept only quality Q&A.
    – Bala
    Commented Apr 23, 2014 at 10:15
0

In my custom form, add your code:

function donation_form($form, &$form_state) {


$form['event_date'] = array(
    '#type' => 'date_popup',
    '#title' => 'Set Date & Time :',
    '#date_format' => 'd-m-y H:i',
    '#default_value' => date('d-m-y H:i'),
    '#date_year_range' => '-3:+3',
    );


  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => 'Submit',
    '#submit' => array('donation_ok'),

  );   

  return $form;
}
 function donation_ok($form, &$form_state) {     
   dpm($form['event_date']['#value']);
   dpm($form_state['values']['event_date']);
   dpm($form_state['input']['event_date']);
 }

enter image description here

you can use:

dpm($form['event_date']['#value']);
dpm($form_state['values']['event_date']);
dpm($form_state['input']['event_date']);

result:

![enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.