You are here

public function Properties::buildConfigurationForm in Salesforce Suite 8.4

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

Implementation of PluginFormInterface::buildConfigurationForm.

Overrides SalesforceMappingFieldPluginBase::buildConfigurationForm

File

modules/salesforce_mapping/src/Plugin/SalesforceMappingField/Properties.php, line 24

Class

Properties
Adapter for entity properties and fields.

Namespace

Drupal\salesforce_mapping\Plugin\SalesforceMappingField

Code

public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
  $pluginForm = parent::buildConfigurationForm($form, $form_state);

  // @TODO inspecting the form and form_state feels wrong, but haven't found a good way to get the entity from config before the config is saved.
  $options = $this
    ->getConfigurationOptions($form['#entity']);

  // Display the plugin config form here:
  if (empty($options)) {
    $pluginForm['drupal_field_value'] = [
      '#markup' => $this
        ->t('No available properties.'),
    ];
  }
  else {
    $pluginForm['drupal_field_value'] += [
      '#type' => 'select',
      '#options' => $options,
      '#empty_option' => $this
        ->t('- Select -'),
      '#default_value' => $this
        ->config('drupal_field_value'),
      '#description' => $this
        ->t('Select a Drupal field or property to map to a Salesforce field.<br />Entity Reference fields should be handled using Related Entity Ids or Token field types.'),
    ];
  }
  return $pluginForm;
}