1

I'm using Drupal 7 and Clean theme.

Can i add date picker in content type field?

Searched about this but i not found any solution.

Users, when click date field, come date picker. Is it possible?

2 Answers 2

4

The Date module has a submodule called "Date Popup" which provides a jQuery UI popup widget for fields.

Just install that module, add a new field to your content type, and when choosing the widget select "Pop-up calendar":

screenshot

2
  • Thank you @Clive but i don't want use module, can i make self in core codes?
    – Karmacoma
    Jun 6, 2012 at 15:24
  • You definitely could do but why would you want to? The date module already provides this functionality. If you want to implement it yourself, you can just copy the relevant bits of code out of the Date API/Date/Date Popup modules and rename the functions/field types. But I can't see any value in doing that, you'll just be reinventing the wheel
    – Clive
    Jun 6, 2012 at 15:27
0

If you want to do it with code it would look something like this.

The callback

function callback($date){

  drupal_add_library('system', 'ui.datepicker');
  drupal_add_js("(function ($) { $('.datepicker').datepicker(); })(jQuery);", array('type' => 'inline', 'scope' => 'footer', 'weight' => 5));

  return theme('my_theme');
}

The template

<input type="text" class="datepicker" name="renewaldate" />

Your Answer

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

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