/**
  * Configures the current widget.
  *
  * Available options:
  *
  *  * format:       The date format string (%month%/%day%/%year% by default)
  *  * years:        An array of years for the year select tag (optional)
  *                  Be careful that the keys must be the years, and the values what will be displayed to the user
  *  * months:       An array of months for the month select tag (optional)
  *  * days:         An array of days for the day select tag (optional)
  *  * can_be_empty: Whether the widget accept an empty value (true by default)
  *  * empty_values: An array of values to use for the empty value (empty string for year, month, and day by default)
  *
  * Available jQuery UI Date picker options:
  *  * ui_date_format:       Date formats, see: http://api.jqueryui.com/datepicker/#utility-formatDate, default is date format for current culture
  *  * ui_number_of_months:  Number of months to display, default is 1
  *  * ui_show_button_panel: Whether to show buttons Today and Done, default is true
  *  * ui_change_month:      Whether to show month drop-down, default is true
  *  * ui_change_year:       Whether to show year drop-down, default is true
  *  * theme:                Which CSS styles to use from themes in config, or default theme will be used set in config. You can set this to null in order not to load any CSS
  *  * ui_constrain_input:   Enable only to input characters defined in date format, default is true
  *
  * Additional options
  *
  *  * ui_button_open:       HTML code for open picker button
  *  * ui_button_clear:      HTML code for clear value button
  *
  * @param array $options     An array of options
  * @param array $attributes  An array of default HTML attributes
  *
  * @see sfWidgetFormDate
  */
 protected function configure($options = array(), $attributes = array())
 {
     parent::configure($options = array(), $attributes = array());
     $this->addOption('ui_date_format', dmContext::getInstance()->getServiceContainer()->getService('user')->getCulture());
     $this->addOption('ui_number_of_months', 1);
     $this->addOption('ui_show_button_panel', true);
     $this->addOption('ui_change_month', true);
     $this->addOption('ui_change_year', true);
     $this->addOption('ui_constrain_input', true);
     $this->addOption('theme', sfConfig::get('dm_dmDatePickerPlugin_default_theme'));
     $this->addOption('ui_button_open', '');
     $this->addOption('ui_button_clear', '');
     if (!isset($options['theme'])) {
         $options['theme'] = $this->getOption('theme');
     }
     sfWidgetFormDmDatePicker::parseThemeDefaultOptions($options, $this);
 }
 protected function parseThemeDefaultOptions($options)
 {
     sfWidgetFormDmDatePicker::parseThemeDefaultOptions($options, $this);
     sfWidgetFormDmTimePicker::parseThemeDefaultOptions($options, $this);
     // Override parsed theme options
     $this->setOption('ui_show_button_panel', $this->defaultOptions['ui_show_button_panel']);
     $this->setOption('ui_button_open', $this->defaultOptions['ui_button_open']);
     $this->setOption('ui_button_clear', $this->defaultOptions['ui_button_clear']);
     $themes = sfConfig::get('dm_dmDateTimePickerPlugin_themes');
     if (isset($options['theme']) && isset($themes[$options['theme']]) && isset($themes[$options['theme']]['defaults'])) {
         $settings = $themes[$options['theme']]['defaults'];
         foreach ($settings as $key => $val) {
             if ($val) {
                 $this->setOption($key, $val);
             }
         }
     }
 }