You are here

public static function PluginSubFormHelpers::buildPluginForm 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.

2 calls to PluginSubFormHelpers::buildPluginForm()
PardotFormMappingForm::buildForm in src/Form/PardotFormMappingForm.php
Form constructor.
WebformSubmissionValue::buildConfigurationForm in src/Plugin/PardotFormMapFormatterPlugin/WebformSubmissionValue.php

File

src/PluginSubFormHelpers.php, line 58

Class

PluginSubFormHelpers
Provides an interface for defining Pardot Form Map entities.

Namespace

Drupal\pardot

Code

public static function buildPluginForm($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_form = $plugin
      ->buildConfigurationForm($plugin_form, $plugin_form_state);
    $plugin_form['#tree'] = TRUE;
    return $plugin_form;
  }
  else {
    return [];
  }
}