Hi,

I'm using this module with some facets (links with checkbox, slider, ...).

The patch for the issue Collapse facet from Facet API and Search API works well.

But, in the block configuration, the option selected isn't saved.

The problem comes from the function collapsiblock_submit($form, &$form_state).
This function transforms and saves a part of the block id in lowercase.
So, I changed the function collapsiblock_form_alter(&$form, $form_state, $form_id) to do the same think and it's working

In the function collapsiblock_form_alter(&$form, $form_state, $form_id), I did this :

function collapsiblock_form_alter(&$form, $form_state, $form_id) {
  [...]
  if ($form_id == 'block_admin_configure') {
    $settings = variable_get('collapsiblock_settings', array());
    $form['#submit'][] = 'collapsiblock_submit';
    $form['collapsiblock'] = array(
      '#type' => 'fieldset',
      '#title' => t('Collapsible'),
      '#collapsible' => TRUE,
      '#weight' => -5
    );

+    $block_id = 'block-' . str_replace('_', '-', $form['module']['#value']) . '-' . drupal_strtolower(str_replace('_', '-', $form['delta']['#value']));
+    if (isset($settings[$block_id])) {
+      $default_value = $settings[$block_id] ? $settings[$block_id] : variable_get('collapsiblock_default_state', 1);
-    if (isset($settings['block-' . str_replace('_', '-', $form['module']['#value']) . '-' . str_replace('_', '-', $form['delta']['#value'])])) {
-      $default_value = $settings['block-' . str_replace('_', '-', $form['module']['#value']) . '-' . str_replace('_', '-', $form['delta']['#value'])] ? $settings['block-' . str_replace('_', '-', $form['module']['#value']) . '-' . str_replace('_', '-', $form['delta']['#value'])] : variable_get('collapsiblock_default_state', 1);
    } else {
      $default_value = 1;
    }
    $form['collapsiblock']['collapse_type'] = array(
      '#type' => 'radios',
      '#title' => t('Block collapse behavior'),
      '#options' => array(1 => t('None.'), 2 => t('Collapsible, expanded by default.'), 3 => t('Collapsible, collapsed by default.'), 4 => t('Collapsible, collapsed all the time.')),
      '#default_value' => $default_value,
    );
  }
}
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Neograph734’s picture

Status: Active » Needs work

I can confirm the problem, but the provided solution doe not work for me. Save works fine, but on reopening the block configuration the previous value is not selected.

rimu’s picture

Works for me. Thanks detroz!

mautumn’s picture

Version: 7.x-1.x-dev » 7.x-1.1
FileSize
1.32 KB

Thanks detroz. I've created a patch of your code (with a tiny change) against the stable 7.x-1.1 version (because it is ahead of dev by about a year!).

darvanen’s picture

@Glossylbis the tagged versions of a module are always drawn from the dev version. The gap you are seeing on the project page is the gap between the last commit to dev, and the date it was tagged as a release. As a matter of best practice please always roll patches against the relevant dev branch.


Also when you are submitting an updated patch it makes it much easier to review if you provide an interdiff. What was the small change you made to @detroz's code?

darvanen’s picture

Adding parent issue.

darvanen’s picture

Got the parent issue wrong.

darvanen’s picture

darvanen’s picture