public function RelatedTermString::buildConfigurationForm in Salesforce Suite 8.4
Same name and namespace in other branches
- 5.0.x modules/salesforce_mapping/src/Plugin/SalesforceMappingField/RelatedTermString.php \Drupal\salesforce_mapping\Plugin\SalesforceMappingField\RelatedTermString::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 SalesforceMappingFieldPluginBase::buildConfigurationForm
File
- modules/
salesforce_mapping/ src/ Plugin/ SalesforceMappingField/ RelatedTermString.php, line 28
Class
- RelatedTermString
- Adapter for entity Reference and fields.
Namespace
Drupal\salesforce_mapping\Plugin\SalesforceMappingFieldCode
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']);
if (empty($options)) {
$pluginForm['drupal_field_value'] += [
'#markup' => $this
->t('No available taxonomy reference fields.'),
];
}
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 taxonomy reference field.<br />If more than one term is referenced, the term at delta zero will be used.<br />A taxonomy reference field will be used to sync to the term name.<br />If a term with the given string does not exist one will be created.'),
];
}
return $pluginForm;
}