Posted by lenkkivihko on February 14, 2009 at 4:30pm
How to enable Datepicker to a text field?
I have installed jquery_ui and jquery_update and jquery_ui into the jquery_ui/jquery_ui (as told in README.txt)
I think what I am missing is to who to add appropriate .js files and .css files to the source code.
Then how to tell that the datepicker should be added to some field.
I would assume they need to be added to form_alter to the form?
Could anyone provide some directions / help?
Thanks in advance!
Comments
How you adding the field,
How you adding the field, with the Form API?
just testing with node example
= Form API.
http://api.drupal.org/api/file/developer/examples/node_example.module/6/...
Harjoituspäiväkirja - www.lenkkivihko.fi
Harjoituspäiväkirja - www.lenkkivihko.fi
Did you figure this out???
Hi
Did you figure how to add a datepicker to a form item???
Thanks
Jeff in Seattle
Jeff in Seattle
enable
enable http://drupal.org/project/jquery_ui
and use this code
<?phpjquery_ui_add(array('ui.datepicker'));
drupal_add_js('$(document).ready(function(){$("#date").datepicker();});','inline');
drupal_add_css("sites/all/modules/jquery_ui/jquery.ui/themes/default/ui.datepicker.css");
?>
------
GiorgosK
Geoland Web development / web marketing
Media Temple Special Offer Codes
How to attach ui.datepicker to a field in a custom module
Hello,
I have tried to attach datepicker to a field and can't seem to get it to work. Could some one please explain how to attach it properly?
Thanks in advance!!!
Here is the snippet:
function dtch_userinit_my_form($form_state) {
jquery_ui_add(array('ui.datepicker'));
drupal_add_js('$(document).ready(function(){$("#date").datepicker();});','inline');
drupal_add_css("sites/all/modules/jquery_ui/jquery.ui/ui/ui.datepicker.js");
/* Other form items...
*/
/* Date picker field
***********/
$form[dtch_userinit_menu]['cl_datepicker'] = array(
'#type' => 'textfield',
'#title' => t('datepicker'),
'#ahah_wrapper' => array(
'path' => 'sites/all/modules/jquery_ui/jquery.ui/ui/ui.datepicker.js' ,
'wrapper' => 'Datepicker'
),
'#default_value' => "",
'#size' => 10,
'#maxlength' => 10,
);
It may help you!
Hi!
This way work for me.
jquery_ui_add(array('ui.datepicker'));drupal_add_js('$(document).ready(function(){$("input#edit-cl-datepicker").datepicker();});','inline');
drupal_add_css("sites/all/modules/jquery_ui/jquery.ui/ui/ui.datepicker.js");
*input#edit-cl-datepicker
/* Date picker field
***********/
$form[dtch_userinit_menu]['cl_datepicker'] = array(
'#type' => 'textfield',
...
);
Couldn't you do all this
Couldn't you do all this using the Date module and adding something like this:
$form['My Example Date Popup'] = array(
'#type' => 'date_popup',
'#title' => 'My Example Date Popup',
'#date_format' => 'Y-m-d g:i a',
'#date_text_parts' => array('year'),
'#date_increment' => 30,
'#date_year_range' => '-1:+3',
'#default_value' => date(Y) . '-01-01',
);