function collapsiblock_form_alter in Collapsiblock 7
Same name and namespace in other branches
- 6 collapsiblock.module \collapsiblock_form_alter()
Implements hook_form_alter().
File
- ./
collapsiblock.module, line 124 - Make blocks collapsible.
Code
function collapsiblock_form_alter(&$form, $form_state, $form_id) {
if ($form_id == 'system_theme_settings') {
$settings = variable_get($form['var']['#value'], array());
$settings = array_merge(collapsiblock_default_settings(), $settings, array());
$form['collapsiblock'] = array(
'#type' => 'fieldset',
'#title' => t('Collapsiblock selectors'),
'#description' => t("Force <a href='http://api.jquery.com/category/selectors/'>CSS selector</a> if collapsiblock doesn't work out of the box"),
'#weight' => 0,
'#attributes' => array(
'id' => 'collapsiblock_form',
),
);
$form['collapsiblock']['collapsiblock_block'] = array(
'#type' => 'textfield',
'#title' => t('Block'),
'#default_value' => $settings['collapsiblock_block'],
);
$form['collapsiblock']['collapsiblock_title'] = array(
'#type' => 'textfield',
'#title' => t('Title'),
'#default_value' => $settings['collapsiblock_title'],
);
$form['collapsiblock']['collapsiblock_content'] = array(
'#type' => 'textfield',
'#title' => t('Block content'),
'#default_value' => $settings['collapsiblock_content'],
);
}
if ($form_id == 'block_admin_configure') {
$settings = variable_get('collapsiblock_settings', array());
$form['#submit'][] = 'collapsiblock_submit';
$form['settings']['collapsiblock'] = array(
'#type' => 'fieldset',
'#title' => t('Collapsible'),
'#collapsible' => TRUE,
);
$block_id = 'block-' . str_replace('_', '-', $form['module']['#value']);
$block_id .= '-' . drupal_strtolower(str_replace('_', '-', $form['delta']['#value']));
$default_value = variable_get('collapsiblock_default_state', 1);
if (isset($settings[$block_id])) {
$default_value = $settings[$block_id];
}
$form['settings']['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,
);
}
}