Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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,
);
}
}
Comment | File | Size | Author |
---|---|---|---|
#3 | block-configuration-not-saved-2491357-0.patch | 1.32 KB | mautumn |
Comments
Comment #1
Neograph734I 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.
Comment #2
rimu CreditAttribution: rimu commentedWorks for me. Thanks detroz!
Comment #3
mautumn CreditAttribution: mautumn as a volunteer commentedThanks 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!).
Comment #4
darvanen@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?
Comment #5
darvanenAdding parent issue.
Comment #6
darvanenGot the parent issue wrong.
Comment #7
darvanenComment #8
darvanen