function visualn_block_form_visualn_iframe_configuration_alter

Implements hook_form_FORM_ID_alter()

Add visualn_block specific iframes configuration settings. Use 'visualn_iframe_configuration' form_id.

See also

\Drupal\visualn_iframe\Form::ConfigurationForm

Related topics

File

modules/visualn_block/visualn_block.module, line 15

Code

function visualn_block_form_visualn_iframe_configuration_alter(&$form, FormStateInterface $form_state, $form_id) {
  $config = \Drupal::config('visualn_block.iframe.settings');
  $form['visualn_block'] = [
    '#type' => 'details',
    '#title' => 'VisualN Block',
    '#open' => FALSE,
  ];
  $form['visualn_block']['allow_blocks_sharing'] = [
    '#type' => 'checkbox',
    '#title' => t('Allow Blocks sharing'),
    '#default_value' => $config
      ->get('allow_blocks_sharing'),
    '#description' => t('Allow sharing for VisualN blocks'),
  ];

  // @todo: add a setting to hide/show exposed share links that wouldn't depend on the setting above
  $form['visualn_block']['implicit_entries_restore'] = [
    '#type' => 'checkbox',
    '#title' => t('Enable missing iframe entries implicit restore'),
    '#default_value' => $config
      ->get('implicit_entries_restore'),
    '#description' => t('Recreate VisualN block drawings on block view if an iframe entry doesn\'t exist. Useful when importing blocks config on other sites. <strong>Should be used only when needed and commonly disabled</strong>.'),
  ];

  // @todo: maybe use array_unshift to execute it first and remove its values
  $form['#submit'][] = 'visualn_block_iframe_configuration_form_submit';
}