You are here

public static function PluginSubFormHelpers::pluginSubmit in Pardot Integration 2.x

Help Submit plugin forms.

Parameters

\Drupal\Core\Plugin\PluginFormInterface $plugin: The plugin instance.

array $form: The form for creating the subform.

\Drupal\Core\Form\FormStateInterface $form_state: The form state to use for creating the subform state.

array $parents: The array parent. Where to get the plugin instance form.

Return value

array|\Drupal\Core\Plugin\PluginFormInterface Either return the plugin or an empty array.

1 call to PluginSubFormHelpers::pluginSubmit()
PardotFormMappingForm::submitForm in src/Form/PardotFormMappingForm.php
Form submission handler.

File

src/PluginSubFormHelpers.php, line 29

Class

PluginSubFormHelpers
Provides an interface for defining Pardot Form Map entities.

Namespace

Drupal\pardot

Code

public static function pluginSubmit($plugin, array &$form, FormStateInterface $form_state, array $parents) {
  if ($plugin instanceof PluginFormInterface) {
    if (!($plugin_form = NestedArray::getValue($form, $parents))) {
      $plugin_form = [];
    }
    $plugin_form_state = SubformState::createForSubform($plugin_form, $form, $form_state);
    $plugin
      ->submitConfigurationForm($plugin_form, $plugin_form_state);
    return $plugin;
  }
  else {
    return [];
  }
}