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?

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

| improve this answer | |
  • Thank you @Clive but i don't want use module, can i make self in core codes? – Karmacoma Jun 6 '12 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 '12 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" />
| improve this answer | |

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.