You are here

private function DefaultValue::getEntityReferenceValues in Pardot Integration 2.x

Get entity reference entity labels.

Parameters

string $field_name: The name of the field we are looking at.

\Drupal\Core\Form\FormStateInterface $form_state: The form state that holds the input values.

Return value

string String of comma seperated entity labels.

1 call to DefaultValue::getEntityReferenceValues()
DefaultValue::getFormattedValue in src/Plugin/PardotFormMapFormatterPlugin/DefaultValue.php

File

src/Plugin/PardotFormMapFormatterPlugin/DefaultValue.php, line 148

Class

DefaultValue
Plugin to select from the list of fields.

Namespace

Drupal\pardot\Plugin\PardotFormMapFormatterPlugin

Code

private function getEntityReferenceValues(string $field_name, FormStateInterface $form_state) {
  $value = [];
  $form_entity = $form_state
    ->getFormObject()
    ->getEntity();
  $selected_entities = $form_entity
    ->get($field_name)
    ->referencedEntities();
  foreach ($selected_entities as $selected_entity) {
    $value[] = $selected_entity
      ->label();
  }
  return implode(',', $value);
}