The Block Form Alter module provides functions to alter block forms consistently across implementing plugins:

  • hook_block_plugin_form_alter()
  • hook_block_type_form_alter()

Block forms are rendered by implementing plugins, which may require duplicate code in some instances where a developer desires to alter a given block form. This is particularly true when altering forms rendered by Layout Builder.

Supported Modules

  • Block (core)
  • Block Content (core)
  • Layout Builder (core)

hook_block_plugin_form_alter()

The hook_block_plugin_form_alter() function allows for block forms to be targeted by plugin id. Block forms rendered by the 'block_content' and 'inline_block' plugins must be altered with hook_block_type_form_alter(). See block_form_alter.api.php for details.

hook_block_type_form_alter()

The hook_block_type_form_alter() function modifies block forms rendered by both Block Content ('block_content' plugin) and Layout Builder ('inline_block' plugin). See block_form_alter.api.php for details.

Related Core Issue

Supporting organizations: 
sponsored initial development

Project information

Releases