You are here

function hook_block_type_form_alter in Block Form Alter 8

Alter custom block forms rendered by Block Content and Layout Builder.

E.g. Alter block forms for 'block_content' and 'inline_block' plugins.

Parameters

array $form: Nested array of form elements that comprise the form.

\Drupal\Core\Form\FormStateInterface $form_state: The form state.

string $block_type: The machine name of the custom block bundle.

1 function implements hook_block_type_form_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

block_form_alter_test_block_type_form_alter in tests/modules/block_form_alter_test/block_form_alter_test.module
Implements hook_block_type_form_alter().
1 invocation of hook_block_type_form_alter()
_block_form_alter_block_type_form_alter_invoke in ./block_form_alter.module
Helper function to alter forms for block_content and inline_block plugins.

File

./block_form_alter.api.php, line 45
Hooks provided by the block_form_alter module.

Code

function hook_block_type_form_alter(array &$form, FormStateInterface &$form_state, string $block_type) {
  if ($block_type == 'accordion') {
    $form['example_field']['widget'][0]['value']['#default_value'] = 'A better default value';
  }
}