public BlockBase::buildConfigurationForm(array $form, FormStateInterface $form_state)
Creates a generic configuration form for all block types. Individual block plugins can add elements to this form by overriding BlockBase::blockForm(). Most block plugins should not override this method unless they need to alter the generic form elements.
Overrides PluginFormInterface::buildConfigurationForm
See also
\Drupal\Core\Block\BlockBase::blockForm()
File
- core/lib/Drupal/Core/Block/BlockBase.php, line 153
Class
- BlockBase
- Defines a base block implementation that most blocks plugins will extend.
Namespace
Drupal\Core\Block
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | public function buildConfigurationForm( array $form , FormStateInterface $form_state ) { $definition = $this ->getPluginDefinition(); $form [ 'provider' ] = array ( '#type' => 'value' , '#value' => $definition [ 'provider' ], ); $form [ 'admin_label' ] = array ( '#type' => 'item' , '#title' => $this ->t( 'Block description' ), '#plain_text' => $definition [ 'admin_label' ], ); $form [ 'label' ] = array ( '#type' => 'textfield' , '#title' => $this ->t( 'Title' ), '#maxlength' => 255, '#default_value' => $this ->label(), '#required' => TRUE, ); $form [ 'label_display' ] = array ( '#type' => 'checkbox' , '#title' => $this ->t( 'Display title' ), '#default_value' => ( $this ->configuration[ 'label_display' ] === BlockInterface::BLOCK_LABEL_VISIBLE), '#return_value' => BlockInterface::BLOCK_LABEL_VISIBLE, ); // Add context mapping UI form elements. $contexts = $form_state ->getTemporaryValue( 'gathered_contexts' ) ? : []; $form [ 'context_mapping' ] = $this ->addContextAssignmentElement( $this , $contexts ); // Add plugin-specific settings for this block type. $form += $this ->blockForm( $form , $form_state ); return $form ; } |
Please login to continue.