Commit e23e7745 authored by legolasbo's avatar legolasbo Committed by Erik Stielstra

Issue #2810783 by mikeker, ransomweaver, nicola85, legolasbo, osman: PHP...

Issue #2810783 by mikeker, ransomweaver, nicola85, legolasbo, osman: PHP exception when placing block
parent fe1fb37a
......@@ -18,6 +18,7 @@ use Drupal\Core\Field\FormatterInterface;
use Drupal\Core\Field\FormatterPluginManager;
use Drupal\Core\Form\FormHelper;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Form\SubformStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Session\AccountInterface;
......@@ -155,6 +156,16 @@ class FieldBlock extends BlockBase implements ContainerFactoryPluginInterface {
* {@inheritdoc}
public function blockForm($form, FormStateInterface $form_state) {
// This method receives a sub form state instead of the full form state.
// There is an ongoing discussion around this which could result in the
// passed form state going back to a full form state. In order to prevent
// future breakage because of a core update we'll just check which type of
// FormStateInterface we've been passed and act accordingly.
// @See
if ($form_state instanceof SubformStateInterface) {
$form_state = $form_state->getCompleteFormState();
$form['label_from_field'] = [
'#title' => $this->t('Use field label as block title'),
'#type' => 'checkbox',
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment