submitConfigurationForm example

/** * {@inheritdoc} */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $this->config('system.image')
      ->set('toolkit', $form_state->getValue('image_toolkit'))
      ->save();

    // Call the form submit handler for each of the toolkits.     foreach ($this->availableToolkits as $toolkit) {
      $toolkit->submitConfigurationForm($form$form_state);
    }

    parent::submitForm($form$form_state);
  }

}
if ($plugin = $this->getPlugin()) {
      $plugin->validateConfigurationForm($form$form_state);
    }
  }

  /** * {@inheritdoc} */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    parent::submitForm($form$form_state);
    if ($plugin = $this->getPlugin()) {
      $plugin->submitConfigurationForm($form$form_state);
    }
  }

  /** * {@inheritdoc} */
  public function save(array $form, FormStateInterface $form_state) {
    $this->entity->save();
    $this->messenger()->addStatus($this->t('The action has been successfully saved.'));

    $form_state->setRedirect('entity.action.collection');
  }
    $this->imageEffect->validateConfigurationForm($form['data'], SubformState::createForSubform($form['data']$form$form_state));
  }

  /** * {@inheritdoc} */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $form_state->cleanValues();

    // The image effect configuration is stored in the 'data' key in the form,     // pass that through for submission.     $this->imageEffect->submitConfigurationForm($form['data'], SubformState::createForSubform($form['data']$form$form_state));

    $this->imageEffect->setWeight($form_state->getValue('weight'));
    if (!$this->imageEffect->getUuid()) {
      $this->imageStyle->addImageEffect($this->imageEffect->getConfiguration());
    }
    $this->imageStyle->save();

    $this->messenger()->addStatus($this->t('The image effect was successfully applied.'));
    $form_state->setRedirectUrl($this->imageStyle->toUrl('edit-form'));
  }

  
/** * {@inheritdoc} */
  public function validateForm(array &$form, FormStateInterface $form_state) {
    $form['#plugin_form']->validateConfigurationForm($form$form_state);
  }

  /** * {@inheritdoc} */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $link = $form['#plugin_form']->submitConfigurationForm($form$form_state);

    $this->messenger()->addStatus($this->t('The menu link has been saved.'));
    $form_state->setRedirect(
      'entity.menu.edit_form',
      ['menu' => $link->getMenuName()]
    );
  }

}
public function validateForm(array &$form, FormStateInterface $form_state) {
    $subform_state = SubformState::createForSubform($form['settings']$form$form_state);
    $this->getPluginForm($this->block)->validateConfigurationForm($form['settings']$subform_state);
  }

  /** * {@inheritdoc} */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    // Call the plugin submit handler.     $subform_state = SubformState::createForSubform($form['settings']$form$form_state);
    $this->getPluginForm($this->block)->submitConfigurationForm($form$subform_state);

    // If this block is context-aware, set the context mapping.     if ($this->block instanceof ContextAwarePluginInterface) {
      $this->block->setContextMapping($subform_state->getValue('context_mapping', []));
    }

    $configuration = $this->block->getConfiguration();

    $section = $this->sectionStorage->getSection($this->delta);
    $section->getComponent($this->uuid)->setConfiguration($configuration);

    
'#default_value' => $this->configuration['langcodes'],
      ];
    }
    return parent::buildConfigurationForm($form$form_state);
  }

  /** * {@inheritdoc} */
  public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
    $this->configuration['langcodes'] = array_filter($form_state->getValue('langcodes'));
    parent::submitConfigurationForm($form$form_state);
  }

  /** * {@inheritdoc} */
  public function summary() {
    $language_list = $this->languageManager->getLanguages(LanguageInterface::STATE_ALL);
    $selected = $this->configuration['langcodes'];
    // Reduce the language list to an array of language names.     $language_names = array_reduce($language_listfunction D$result$item) use ($selected) {
      // If the current item of the $language_list array is one of the selected

  public function testSubmitConfigurationForm() {
    $display_variant = $this->setUpDisplayVariant();
    $this->assertSame('', $display_variant->label());

    $form = [];
    $label = $this->randomMachineName();
    $form_state = new FormState();
    $form_state->setValue('label', $label);
    $display_variant->submitConfigurationForm($form$form_state);
    $this->assertSame($label$display_variant->label());
  }

}
public function save(array $form, FormStateInterface $form_state) {
    /** @var \Drupal\workflows\WorkflowInterface $workflow */
    $workflow = $this->entity;
    $workflow_type = $workflow->getTypePlugin();
    $transition = $workflow_type->getTransition($form_state->getValue('id'));

    if ($workflow_type->hasFormClass(TransitionInterface::PLUGIN_FORM_KEY)) {
      $subform_state = SubformState::createForSubform($form['type_settings']$form$form_state);
      $subform_state->set('transition', $transition);
      $this->pluginFormFactory
        ->createInstance($workflow_type, TransitionInterface::PLUGIN_FORM_KEY)
        ->submitConfigurationForm($form['type_settings']$subform_state);
    }

    $workflow->save();
    $this->messenger()->addStatus($this->t('Created %label transition.', [
      '%label' => $form_state->getValue('label'),
    ]));
    $form_state->setRedirectUrl($workflow->toUrl('edit-form'));
  }

  /** * {@inheritdoc} */
return $theme_info->info['name'];
      }$this->themeHandler->listInfo()),
    ];
    return parent::buildConfigurationForm($form$form_state);
  }

  /** * {@inheritdoc} */
  public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
    $this->configuration['theme'] = $form_state->getValue('theme');
    parent::submitConfigurationForm($form$form_state);
  }

  /** * {@inheritdoc} */
  public function evaluate() {
    if (!$this->configuration['theme']) {
      return TRUE;
    }

    return $this->themeManager->getActiveTheme()->getName() == $this->configuration['theme'];
  }
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
    $this->plugin->validateConfigurationForm($form$form_state);
    if (!$this->hasMenuOverrides()) {
      $this->getEntityForm($this->menu)->validateForm($form$form_state);
    }
  }

  /** * {@inheritdoc} */
  public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
    $this->plugin->submitConfigurationForm($form$form_state);
    if (!$this->hasMenuOverrides()) {
      $this->getEntityForm($this->menu)->submitForm($form$form_state);
      $this->menu->save();
    }
  }

  /** * Gets the entity form for this menu. * * @param \Drupal\system\MenuInterface $menu * The menu entity. * * @return \Drupal\Core\Entity\EntityFormInterface * The entity form. */
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
    parent::validateConfigurationForm($form$form_state);
    if ($form_state->isValueEmpty('width') && $form_state->isValueEmpty('height')) {
      $form_state->setErrorByName('data', $this->t('Width and height can not both be blank.'));
    }
  }

  /** * {@inheritdoc} */
  public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
    parent::submitConfigurationForm($form$form_state);

    $this->configuration['upscale'] = $form_state->getValue('upscale');
  }

}

  public function validateForm(array &$form, FormStateInterface $form_state) {
    $subformState = SubformState::createForSubform($form['entity_bundle']$form$form_state);
    $this->condition->validateConfigurationForm($form['entity_bundle']$subformState);
  }

  /** * {@inheritdoc} */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $subformState = SubformState::createForSubform($form['entity_bundle']$form$form_state);
    $this->condition->submitConfigurationForm($form['entity_bundle']$subformState);
    $subformState = SubformState::createForSubform($form['current_theme']$form$form_state);

    $this->conditionCurrentTheme->submitConfigurationForm($form['current_theme']$subformState);
    $config = $this->condition->getConfig();
    foreach ($config['bundles'] as $bundle) {
      \Drupal::messenger()->addStatus('Bundle: ' . $bundle);
    }

    $article = Node::load(1);
    $this->condition->setContextValue('node', $article);
    if ($this->condition->execute()) {
      
// If this plugin is configurable but has not yet had user interaction,       // the default configuration will still be active and may trigger       // validation errors. Do not trigger those validation errors until the       // form is actually saved, to allow the user to first configure other       // CKEditor 5 functionality.       $default_configurations[$plugin_id] = $default_configuration;

      if ($form_state->hasValue(['plugins', $plugin_id])) {
        $subform = $form['plugins'][$plugin_id];
        $subform_state = SubformState::createForSubform($subform$form$form_state);
        $plugin->validateConfigurationForm($subform$subform_state);
        $plugin->submitConfigurationForm($subform$subform_state);

        // If the configuration is stored out of band, ::submitConfigurationForm         // will already have stored it. If it is not stored out of band,         // populate $settings, to populate $submitted_editor.         if (!$configuration_stored_out_of_band) {
          $settings['plugins'][$plugin_id] = $plugin->getConfiguration();
        }
      }
      // @see \Drupal\ckeditor5\Plugin\Editor\CKEditor5::injectPluginSettingsForm()       elseif ($this->shouldHaveVisiblePluginSettingsForm($definition$eventual_editor_and_format_for_plugin_settings_visibility)) {
        if (!$configuration_stored_out_of_band) {
          

    ));

    parent::submitForm($form$form_state);

    $this->entity->setQueueThumbnailDownloadsStatus((bool) $form_state->getValue(['options', 'queue_thumbnail_downloads']))
      ->setStatus((bool) $form_state->getValue(['options', 'status']))
      ->setNewRevision((bool) $form_state->getValue(['options', 'new_revision']));

    if (isset($form['source_dependent']['source_configuration'])) {
      // Let the selected plugin save its settings.       $this->entity->getSource()->submitConfigurationForm($form['source_dependent']['source_configuration']$this->getSourceSubFormState($form$form_state));
    }
  }

  /** * {@inheritdoc} */
  protected function actions(array $form, FormStateInterface $form_state) {
    $actions = parent::actions($form$form_state);

    // If the media source has not been chosen yet, turn the submit button into     // a button. This rebuilds the form with the media source's configuration
public function save(array $form, FormStateInterface $form_state) {
    /** @var \Drupal\workflows\WorkflowInterface $workflow */
    $workflow = $this->entity;
    $workflow_type = $workflow->getTypePlugin();
    $transition = $workflow_type->getTransition($this->transitionId);

    if ($workflow_type->hasFormClass(TransitionInterface::PLUGIN_FORM_KEY)) {
      $subform_state = SubformState::createForSubform($form['type_settings']$form$form_state);
      $subform_state->set('transition', $transition);
      $this->pluginFormFactory
        ->createInstance($workflow_type, TransitionInterface::PLUGIN_FORM_KEY)
        ->submitConfigurationForm($form['type_settings']$subform_state);
    }

    $workflow->save();
    $this->messenger()->addStatus($this->t('Saved %label transition.', [
      '%label' => $workflow->getTypePlugin()->getTransition($this->transitionId)->label(),
    ]));
    $form_state->setRedirectUrl($workflow->toUrl('edit-form'));
  }

  /** * {@inheritdoc} */
Home | Imprint | This part of the site doesn't use cookies.