1

I am using a date field in a content type. I want to make it work similar to the date/time input in facebook events. When I use date field as a Pop-up calendar it appears like this:

enter image description here

For date input it is fine as it is – but for the time imput I would prefer to have a drop down field (select list) with the date input as pop-up calender here. When I try this...

$dropdown_time_array = array('12:00 pm','12:15 pm','12:30 pm','12:45 pm', );
if($form_id == $form_id_node){
$form['field_date'] = array(     
     '#type' => 'select',
     '#default_value' => '1',        
     '#options' => $dropdown_time_array,
  ); 
}

…it actually overrides the whole field – including the date input.

Any suggestions how I can do this?

1

You can tell the Pop-up date widget to use wvega-timepicker depending whether you're using a Date field or custom module there are different ways of using it.

0

What I would do to find out what you need to type is to insert a debug statement.

Enable the devel module and then just before the code you have added above add in dpm($form);

This will show you the structure of the array. You will need to change your code to something like this, but please don't just copy what I did, it's not exactly right - get the actual name of the sub-field from looking at the array (if you are not sure, post your debug output).

$form['field_date']['time'] = array(

Once you have the answer, of course you remove the debug code and turn of devel again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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