You are here

public function DashboardBlockConfigForm::submitForm in Content Planner 8

Form submission handler.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides ConfigFormBase::submitForm

File

src/Form/DashboardBlockConfigForm.php, line 167

Class

DashboardBlockConfigForm
Defines a form that configures forms module settings.

Namespace

Drupal\content_planner\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {

  // Get block id from from state.
  $block_id = $form_state
    ->getValue('block_id');

  // Get specific block configuration.
  $block_configuration = $this->dashboardSettingsService
    ->getBlockConfiguration($block_id);

  // Set fields.
  $block_configuration['title'] = $form_state
    ->getValue('title');
  $block_configuration['weight'] = $form_state
    ->getValue('weight');
  $block_configuration['configured'] = TRUE;
  $block_configuration['plugin_specific_config'] = $form_state
    ->getValue('plugin_specific_config');

  // Save configurations back into config.
  $this->dashboardSettingsService
    ->saveBlockConfiguration($block_id, $block_configuration);
}