You are here

README.txt in Date Restrictions 7

Description
===========

Restricts allowed values in date fields, and datepicker popup widget.

Installation
============

As usual.

Configuration and Usage
=======================

 * Create or edit a date field.
 * Configure under "More settings and values" > "Restrictions".

Code example
============

$date_format = date_limit_format(variable_get('date_format_short'), array('year', 'month', 'day'));
$form['date'] = array(
  '#type' => 'date_popup',
  '#flavour' => 'inline', // Requires date_datepicker_inline module.
  '#date_format' => $date_format,
  '#default_value' => $date->format(DATE_FORMAT_DATE),
  '#restrictions' => array(
    'min' => array(
      'type' => 'date',
      'date' => $date_range[0]['value'],
    ),
    'max' => array(
      'type' => 'interval', // Requires interval module.
      'interval' => array('interval' => 3, 'period' => 'months'),
    ),
    'allowed_values' => array(
      'type' => 'weekdays', // Requires weekdays module.
      'weekdays' => array('SA', 'SU'),
    ),
  ),
);

File

README.txt
View source
  1. Description
  2. ===========
  3. Restricts allowed values in date fields, and datepicker popup widget.
  4. Installation
  5. ============
  6. As usual.
  7. Configuration and Usage
  8. =======================
  9. * Create or edit a date field.
  10. * Configure under "More settings and values" > "Restrictions".
  11. Code example
  12. ============
  13. $date_format = date_limit_format(variable_get('date_format_short'), array('year', 'month', 'day'));
  14. $form['date'] = array(
  15. '#type' => 'date_popup',
  16. '#flavour' => 'inline', // Requires date_datepicker_inline module.
  17. '#date_format' => $date_format,
  18. '#default_value' => $date->format(DATE_FORMAT_DATE),
  19. '#restrictions' => array(
  20. 'min' => array(
  21. 'type' => 'date',
  22. 'date' => $date_range[0]['value'],
  23. ),
  24. 'max' => array(
  25. 'type' => 'interval', // Requires interval module.
  26. 'interval' => array('interval' => 3, 'period' => 'months'),
  27. ),
  28. 'allowed_values' => array(
  29. 'type' => 'weekdays', // Requires weekdays module.
  30. 'weekdays' => array('SA', 'SU'),
  31. ),
  32. ),
  33. );