How can I save the configuration value in a custom submit form method I've been wondering if it was possible to use the configuration system instead of playing directly with the database. Here's a simplified version of what I'm trying to achieve:

public function blockForm($form, FormStateInterface $form_state) {
    $form = parent::blockForm($form, $form_state);
    $form['action'] = array(
        '#type' =&gt; 'submit',
        '#submit' =&gt; [[$this, 'myMethod']],
        '#value' =&gt; $this-&gt;t('Test')
    );
    return $form;
}

public function myMethod($form, FormStateInterface $form_state) {
    $this-&gt;setConfigurationValue('my_config', 'my test value!');
    $this-&gt;saveConfiguration(); // &lt;---- Is that 'kind of' possible?
}


So, I was wondering if it was possible to get the real "config class" by some way and call $config-&gt;save(). I started to look at the source and I think it's probably possible using the configuration engine.

Any help would be appreciated.

Thanks
The blockForm is used to configure a block. The configuration is then used to build the block.

If you want to use the configuration system to store data in the database use one of these methods:


Simple Configuration Form 
Creating a configuration entity
type