function collapsiblock_form_block_form_alter in Collapsiblock 4.x
Same name and namespace in other branches
- 8.2 collapsiblock.module \collapsiblock_form_block_form_alter()
- 8 collapsiblock.module \collapsiblock_form_block_form_alter()
- 3.x collapsiblock.module \collapsiblock_form_block_form_alter()
Implements hook_form_FORM_ID_alter().
File
- ./
collapsiblock.module, line 41 - Make blocks collapsible.
Code
function collapsiblock_form_block_form_alter(&$form, FormStateInterface $form_state, $form_id) {
$form['collapsiblock_settings'] = [
'#type' => 'details',
'#title' => t('Collapsible'),
'#open' => TRUE,
];
// Add the global default to the list of options for the per-block setting.
$block = $form_state
->getFormObject()
->getEntity();
$options = unserialize(COLLAPSIBLOCK_ACTION_OPTIONS);
$settings = \Drupal::config('collapsiblock.settings');
$default_action = $options[$settings
->get('default_action')];
$options = [
0 => 'Global default, currently set to: ' . $default_action,
] + $options;
$form['collapsiblock_settings']['collapse_action'] = [
'#type' => 'radios',
'#title' => t('Block collapse behavior'),
'#options' => $options,
'#default_value' => $block
->getThirdPartySetting('collapsiblock', 'collapse_action', 0),
];
$form['#entity_builders'][] = 'collapsiblock_block_form_form_builder';
}