Hi,
I'm using date_picker in my module. I have the following code:
$form['start'] = array(
'#title' => t('Arrive'),
'#type' => 'date_popup',
'#default_value' => 'YYYY-MM-DD',
'#date_year_range' => '0:+3',
'#size' => 12,
'#required' => true,
);
But the time field is displayed, though the field is not required and not specified in #default_value.
Is there a way that the time field component can be removed when using '#type' => 'date_popup' in a custom module?
Many thanks for any light you can shed on this matter.
Comments
Comment #1
karens commentedYou don't have this set up right. You need a complete date, like YYYY-MM-DD HH:MM:SS for the default date (you can use zeros for non-needed hours, minutes, and seconds), and you also need #date_format, which is where you identify that you only want a year, month, and day, like 'Y-m-d'.
Comment #2
baronmunchowsen commentedHi KarenS
Thankyou for your help. This worked like a charm:
Comment #4
abdelatifs commented$form['rental_date']['pick_up'] = array(
'#type' => 'date_popup',
'#title' => 'Pick Up Date',
'#date_format' => 'm/d/Y',
'#default_value' => 'YYYY-MM-DD 00:00:00',
'#size' => 10,
'#maxlength' => 15,
'#required' => TRUE,
);
I've tried this and the field is populated correctly. But when I submit my form and try to display the result i get this: "2011-01-14 00:00:00" when i'd like to get this "01/14/2011"
Any reason why?
Thank you guys
Comment #5
Mohamed Hafez commentedthank u the below code is working with me as charm