public function PardotFormMappingForm::buildForm in Pardot Integration 2.x
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides FormInterface::buildForm
File
- src/
Form/ PardotFormMappingForm.php, line 41
Class
- PardotFormMappingForm
- Class PardotFormMappingForm.
Namespace
Drupal\pardot\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$formMapPluginManager = $this->pluginManagerFormMapHandlerPlugin;
$entity = func_get_args()[2];
$form_map_plugin_instance_id = func_get_args()[3] ?? '';
if ($entity && $form_map_plugin_instance_id) {
$form_state
->set('entity', $entity);
$form_state
->set('form_map_plugin_instance_id', $form_map_plugin_instance_id);
$plugin = $formMapPluginManager
->createInstance($form_map_plugin_instance_id);
$settings = [
$entity
->getEntityTypeId() => $entity
->id(),
'entity_id' => $entity
->id(),
];
if ($plugin_settings = $entity
->getThirdPartySetting('pardot', 'pardot_form_mapping_plugin', FALSE)) {
$settings['settings'] = $plugin_settings['settings'];
}
$plugin
->setConfiguration($settings);
$form['pardot_form_mapping'] = PluginSubFormHelpers::buildPluginForm($plugin, $form, $form_state, [
'pardot_form_mapping',
]);
}
$form['submit'] = [
'#type' => 'submit',
'#value' => $this
->t('Submit'),
];
return $form;
}