public function BlockFieldWidget::configurationForm in Block field 8
Ajax callback that return block configuration setting form.
File
- src/
Plugin/ Field/ FieldWidget/ BlockFieldWidget.php, line 206
Class
- BlockFieldWidget
- Plugin implementation of the 'block_field' widget.
Namespace
Drupal\block_field\Plugin\Field\FieldWidgetCode
public function configurationForm(array $form, FormStateInterface $form_state) {
$trigger_element = $form_state
->getTriggeringElement();
$array_parents = $trigger_element['#array_parents'];
$array_parents[count($array_parents) - 1] = 'settings';
$settings_element = NestedArray::getValue($form, $array_parents);
// Set the label #value to the default block instance's label.
$plugin_id = $trigger_element['#value'];
/** @var \Drupal\Core\Block\BlockPluginInterface $block_instance */
if ($block_instance = $this->blockManager
->createInstance($plugin_id)) {
$settings_element['label']['#value'] = $block_instance
->label();
}
return $settings_element;
}