Fix for Trouble with default values on form fields within fieldsets

  1. /* Only pasted the revelant code here for readability */
  2.  
  3. class views_accordion_style_plugin extends views_plugin_style {
  4. /**
  5.    * Set default options
  6.    */
  7.   function option_definition() {
  8.     $options = parent::option_definition();
  9.     $options['auto-cycle-settings'] = array(
  10.       'auto-cycle' => array('default' => 0),
  11.       'auto-cycle-speed' => array('default' => 5),
  12.       );
  13.     return $options;
  14.   }
  15.  
  16.   function options_form(&$form, &$form_state) {
  17.     parent::options_form($form, $form_state);
  18.     $form['auto-cycle-settings'] = array(
  19.       '#type' => 'fieldset',
  20.       '#title' => t('Auto cycle settings'),
  21.       '#weight' => 4,
  22.       '#collapsible' => TRUE,
  23.       '#collapsed' => TRUE,
  24.     );
  25.     $form['auto-cycle-settings']['auto-cycle'] = array(
  26.       '#type' => 'checkbox',
  27.       '#title' => t('Auto cycle through the items'),
  28.       '#default_value' => $this->options['auto-cycle-settings']['auto-cycle'],
  29.     );
  30.     $form['auto-cycle-settings']['auto-cycle-speed'] = array(
  31.       '#type' => 'textfield',
  32.       '#title' => t('Cycle transition time'),
  33.       '#size' => 5,
  34.       '#maxlength' => 5,
  35.       '#default_value' => $this->options['auto-cycle-settings']['auto-cycle-speed'],
  36.       '#field_suffix' => t('Seconds'),
  37.       '#required' => FALSE,
  38.       '#element_validate' => array('accordion_cycle_speed_validate'),
  39.     );

Submit Fix

Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Select the syntax highlighting mode to use.