This blog describes how to add date pop-up calender to a custom form in the Drupal maintenance support plans 7. The use case is if you want to use date pop-up calendar in a custom form, then how you can do it in the drupal 7. Actually, the drupal 7 form API provides lots of form types like textfield, checkbox, checkboxes etc to create a custom form. Similarly, the date module also provides the form type called date_popup. We can use it in the custom form in order to display the date pop-up in the custom form.Use date pop-up calendar with the custom form in drupal 7: Let consider the below code snippet: function phponwebsites_menu() { $items = array(); $items[‘customform’] = array( ‘title’ => t(‘Custom Form’), ‘type’ => MENU_CALLBACK, ‘page callback’ => ‘drupal_get_form’, ‘page arguments’ => array(‘phponwebsites_display_date_popup_form’), ‘access callback’ => TRUE, ); return $items;}function phponwebsites_display_date_popup_form($form, &$form_state) { $form[‘date’] = array( ‘#type’ => ‘date_popup’, ‘#default_value’ => date(‘Y-m-d’), ‘#date_format’ => ‘Y-m-d’, ‘#date_year_range’ => ‘0:+5’, ‘#datepicker_options’ => array(‘minDate’ => 0, ‘maxDate’ => 0), ); return $form;} Where, ‘#date_format’ => ‘Y-m-d’ if you need to display only date ‘#date_format’ => ‘Y-m-d H:i:s’ if you need to display date & time ‘#date_year_range’ => ‘0:+5’ if you need to display only future 5 years ‘#datepicker_options’ => array(‘minDate’ => 0, ‘maxDate’ => 0) if you want to display only current date. We can hide the future & past dates using this option. Please add the above code into your module file and look into the “customform” page. It looks like the below image: Now I’ve hope you know how to add date pop-up calendar with custom form in the drupal 7. Related articles:Remove speical characters from URL alias using pathauto module in Drupal maintenance support plans 7Add new menu item into already created menu in Drupal maintenance support plans 7Add class into menu item in Drupal maintenance support plans 7Create menu tab programmatically in Drupal maintenance support plans 7Add custom fields to search api index in Drupal maintenance support plans 7Clear views cache when insert, update and delete a node in Drupal maintenance support plans 7Create a page without header and footer in Drupal maintenance support plans 7Login using both email and username in Drupal maintenance support plans 7Disable future dates in date pop-up calendar Drupal maintenance support plans 7
Source: New feed
Add date pop-up calendar in custom drupal 7 form

Call Us: 1(800)730-2416
Pixeldust is a 20-year-old web development agency specializing in Drupal and WordPress and working with clients all over the country. With our best in class capabilities, we work with small businesses and fortune 500 companies alike. Give us a call at 1(800)730-2416 and let’s talk about your project.

FREE Drupal SEO Audit
Test your site below to see which issues need to be fixed. We will fix them and optimize your Drupal site 100% for Google and Bing. (Allow 30-60 seconds to gather data.)
Add date pop-up calendar in custom drupal 7 form
On-Site Drupal SEO Master Setup
We make sure your site is 100% optimized (and stays that way) for the best SEO results.
With Pixeldust On-site (or On-page) SEO we make changes to your site’s structure and performance to make it easier for search engines to see and understand your site’s content. Search engines use algorithms to rank sites by degrees of relevance. Our on-site optimization ensures your site is configured to provide information in a way that meets Google and Bing standards for optimal indexing.
This service includes:
- Pathauto install and configuration for SEO-friendly URLs.
- Meta Tags install and configuration with dynamic tokens for meta titles and descriptions for all content types.
- Install and fix all issues on the SEO checklist module.
- Install and configure XML sitemap module and submit sitemaps.
- Install and configure Google Analytics Module.
- Install and configure Yoast.
- Install and configure the Advanced Aggregation module to improve performance by minifying and merging CSS and JS.
- Install and configure Schema.org Metatag.
- Configure robots.txt.
- Google Search Console setup snd configuration.
- Find & Fix H1 tags.
- Find and fix duplicate/missing meta descriptions.
- Find and fix duplicate title tags.
- Improve title, meta tags, and site descriptions.
- Optimize images for better search engine optimization. Automate where possible.
- Find and fix the missing alt and title tag for all images. Automate where possible.
- The project takes 1 week to complete.
