You are here

public function SalesforceMappingFieldPluginBase::buildConfigurationForm in Salesforce Suite 8.4

Same name and namespace in other branches
  1. 8.3 modules/salesforce_mapping/src/SalesforceMappingFieldPluginBase.php \Drupal\salesforce_mapping\SalesforceMappingFieldPluginBase::buildConfigurationForm()
  2. 5.0.x modules/salesforce_mapping/src/SalesforceMappingFieldPluginBase.php \Drupal\salesforce_mapping\SalesforceMappingFieldPluginBase::buildConfigurationForm()

Form constructor.

Plugin forms are embedded in other forms. In order to know where the plugin form is located in the parent form, #parents and #array_parents must be known, but these are not available during the initial build phase. In order to have these properties available when building the plugin form's elements, let this method return a form element that has a #process callback and build the rest of the form in the callback. By the time the callback is executed, the element's #parents and #array_parents properties will have been set by the form API. For more documentation on #parents and #array_parents, see \Drupal\Core\Render\Element\FormElement.

Parameters

array $form: An associative array containing the initial structure of the plugin form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form. Calling code should pass on a subform state created through \Drupal\Core\Form\SubformState::createForSubform().

Return value

array The form structure.

Overrides PluginFormInterface::buildConfigurationForm

13 calls to SalesforceMappingFieldPluginBase::buildConfigurationForm()
Broken::buildConfigurationForm in modules/salesforce_mapping/src/Plugin/SalesforceMappingField/Broken.php
Form constructor.
Constant::buildConfigurationForm in modules/salesforce_mapping/src/Plugin/SalesforceMappingField/Constant.php
Form constructor.
DrupalConstant::buildConfigurationForm in modules/salesforce_mapping/src/Plugin/SalesforceMappingField/DrupalConstant.php
Form constructor.
Hardcoded::buildConfigurationForm in modules/salesforce_example/src/Plugin/SalesforceMappingField/Hardcoded.php
Form constructor.
Properties::buildConfigurationForm in modules/salesforce_mapping/src/Plugin/SalesforceMappingField/Properties.php
Implementation of PluginFormInterface::buildConfigurationForm.

... See full list

13 methods override SalesforceMappingFieldPluginBase::buildConfigurationForm()
Broken::buildConfigurationForm in modules/salesforce_mapping/src/Plugin/SalesforceMappingField/Broken.php
Form constructor.
Constant::buildConfigurationForm in modules/salesforce_mapping/src/Plugin/SalesforceMappingField/Constant.php
Form constructor.
DrupalConstant::buildConfigurationForm in modules/salesforce_mapping/src/Plugin/SalesforceMappingField/DrupalConstant.php
Form constructor.
Hardcoded::buildConfigurationForm in modules/salesforce_example/src/Plugin/SalesforceMappingField/Hardcoded.php
Form constructor.
Properties::buildConfigurationForm in modules/salesforce_mapping/src/Plugin/SalesforceMappingField/Properties.php
Implementation of PluginFormInterface::buildConfigurationForm.

... See full list

File

modules/salesforce_mapping/src/SalesforceMappingFieldPluginBase.php, line 378

Class

SalesforceMappingFieldPluginBase
Defines a base Salesforce Mapping Field Plugin implementation.

Namespace

Drupal\salesforce_mapping

Code

public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
  $pluginForm = [];
  $plugin_def = $this
    ->getPluginDefinition();

  // Extending plugins will probably inject most of their own logic here:
  $pluginForm['drupal_field_value'] = [
    '#title' => $plugin_def['label'],
  ];
  $options = $this
    ->getSalesforceFieldOptions($form['#entity']
    ->getSalesforceObjectType());
  $pluginForm['salesforce_field'] = [
    '#title' => $this
      ->t('Salesforce field'),
    '#type' => 'select',
    '#description' => $this
      ->t('Select a Salesforce field to map.'),
    '#options' => $options,
    '#default_value' => $this
      ->config('salesforce_field'),
    '#empty_option' => $this
      ->t('- Select -'),
  ];
  $pluginForm['direction'] = [
    '#title' => $this
      ->t('Direction'),
    '#type' => 'radios',
    '#options' => [
      MappingConstants::SALESFORCE_MAPPING_DIRECTION_DRUPAL_SF => $this
        ->t('Drupal to SF'),
      MappingConstants::SALESFORCE_MAPPING_DIRECTION_SF_DRUPAL => $this
        ->t('SF to Drupal'),
      MappingConstants::SALESFORCE_MAPPING_DIRECTION_SYNC => $this
        ->t('Sync'),
    ],
    '#required' => TRUE,
    '#default_value' => $this
      ->config('direction') ? $this
      ->config('direction') : MappingConstants::SALESFORCE_MAPPING_DIRECTION_SYNC,
    '#attributes' => [
      'class' => [
        'narrow',
      ],
    ],
  ];
  $pluginForm['description'] = [
    '#title' => t('Description'),
    '#type' => 'textarea',
    '#description' => t('Details about this field mapping.'),
    '#default_value' => $this
      ->config('description'),
  ];
  return $pluginForm;
}