Hi everyone,

I need your help for creating date_popup field in a form programmatically.

Here is the array i use (i simplified it/deleted some parameters like #format) :

	'profil_date' => array(
	  '#type' => 'date_popup', 
	  '#title' => t('Date de naissance'),   
	),

And it doesn't work. With date_select or date_text, no problem, but not with date_popup.

I found this snippet, which works, but i'm not able to use any parameters (format or date_year_range) with the created field.

I can't find out why it's not working, because my popups calendar are working perfectly everywhere else on my website.

For example, if I use kpr($form) on a view wich has a popup calendar date filter, here is what I obtain :


min (Array, 8 elements)

#type (String, 10 characters ) date_popup
#title (String, 8 characters ) Entre le
#size (Integer) 20
#default_value (String, 19 characters ) 2011-02-17 18:34:36
#date_format (String, 5 characters ) d/m/y
#date_label_position (String, 6 characters ) within
#date_year_range (String, 5 characters ) -3:+3
#force_value (Boolean) TRUE

So the type of the field is "date_popup" ! And not "textfield" as in the working snippet...

How can I use "date_popup" ?
Is that related to a jQuery issue ?

I think i'm just missing some .js file(s), but I wish you could guide me in the right direction.

Thanks everyone !

Matthieu

Comments

SandraVdv’s picture

Hi,

You can do this by implementing a hook_form_alter where you put following code:

$form['date'] = array(
        '#type' => 'date_popup',
        '#title' => t('Date'),
        '#date_format' => 'd/m/Y',
        '#weight' => 1
      );

I think this is what you need, right?

danisha’s picture

What about if you need to make a field date_popup in exposed filter of node posted. I dont know why in drupal 6 views 2 this functionality is not working??? Can you please help me with that?

jiv_e’s picture

Status: Active » Closed (won't fix)

I'm sorry you didn't get any further support on this. This issue is getting old with no activity. I'm cleaning the issue queue, so I'll close this. Please feel free to reopen if needed!