You are here

function entityblock_form_block_form_alter in Entityblock 8

Implements hook_form_FORM_ID_alter() for block_form.

File

./entityblock.module, line 23
Enables users to turn entities in blocks.

Code

function entityblock_form_block_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  if ($form['settings']['provider']['#value'] == 'entityblock') {
    $form['settings']['label']['#states'] = [
      'enabled' => [
        ':input[name="settings[label_override]"]' => [
          'checked' => TRUE,
        ],
      ],
    ];

    // Remove token validator as entity block has the token and that one is validated.
    if (\Drupal::moduleHandler()
      ->moduleExists('token')) {
      $delta = array_search('token_element_validate', $form['settings']['label']['#element_validate']);
      unset($form['settings']['label']['#element_validate'][$delta]);
    }
  }
}