When I set a storage value on the form state in my blockForm method of Drupal\Core\Block\BlockBase, the storage array is empty on the blockSubmit method.

Example:

<?php
    public function blockForm($form, FormStateInterface $form_state)
    {
        $form_state->set('test', 'Testing');
        
        $form = parent::blockForm($form, $form_state);

        // [...]

        return $form;
    }


    public function blockSubmit($form, FormStateInterface $form_state)
    {
        $this->setConfigurationValue('non_form_value', $form_state->get('test')); // FormState::$storage is empty
    }
?>

Any ideas why this is not working?

Comments

asent created an issue. See original summary.

amsentner’s picture

Issue summary: View changes
xano’s picture

Status: Active » Closed (duplicate)

Good find! We're working on a fix in #2537732: PluginFormInterface must have access to the complete $form_state (introduce SubFormState for embedded forms). I'm marking this a duplicate of the other issue.