You are here

public function SalesforceMappingFieldsForm::addField in Salesforce Suite 8.4

Same name and namespace in other branches
  1. 5.0.x modules/salesforce_mapping_ui/src/Form/SalesforceMappingFieldsForm.php \Drupal\salesforce_mapping_ui\Form\SalesforceMappingFieldsForm::addField()

File

modules/salesforce_mapping_ui/src/Form/SalesforceMappingFieldsForm.php, line 292

Class

SalesforceMappingFieldsForm
Salesforce Mapping Fields Form.

Namespace

Drupal\salesforce_mapping_ui\Form

Code

public function addField(&$form, FormStateInterface $form_state) {
  $trigger = $form_state
    ->getTriggeringElement();
  $values =& $form_state
    ->getValues();
  $new_field = NestedArray::getValue($values, [
    'buttons',
    'field_type',
  ]);
  if (in_array('add', $trigger['#array_parents']) && !empty($new_field) && $trigger['#name'] != 'context_drupal_field_value') {
    NestedArray::setValue($values, [
      'buttons',
      'new_field',
    ], $new_field);
  }
  $form_state
    ->setRebuild(TRUE);
}