You are here

public function DevelGenerateForm::submitForm in Devel 8

Same name and namespace in other branches
  1. 8.3 devel_generate/src/Form/DevelGenerateForm.php \Drupal\devel_generate\Form\DevelGenerateForm::submitForm()
  2. 8.2 devel_generate/src/Form/DevelGenerateForm.php \Drupal\devel_generate\Form\DevelGenerateForm::submitForm()
  3. 4.x devel_generate/src/Form/DevelGenerateForm.php \Drupal\devel_generate\Form\DevelGenerateForm::submitForm()

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 FormInterface::submitForm

File

devel_generate/src/Form/DevelGenerateForm.php, line 102

Class

DevelGenerateForm
Defines a form that allows privileged users to generate entities.

Namespace

Drupal\devel_generate\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  try {
    $plugin_id = $this
      ->getPluginIdFromRequest();
    $instance = $this
      ->getPluginInstance($plugin_id);
    $instance
      ->generate($form_state
      ->getValues());
  } catch (DevelGenerateException $e) {
    $this
      ->logger('DevelGenerate', $this
      ->t('Failed to generate elements due to "%error".', array(
      '%error' => $e
        ->getMessage(),
    )));
    drupal_set_message($this
      ->t('Failed to generate elements due to "%error".', array(
      '%error' => $e
        ->getMessage(),
    )));
  }
}