You are here

public function DefaultValue::getContactFormFieldCollection in Pardot Integration 2.x

Get the list of fields to map with.

Return value

array|mixed|null Just return the mapped field container.

1 call to DefaultValue::getContactFormFieldCollection()
DefaultValue::buildConfigurationForm in src/Plugin/PardotFormMapFormatterPlugin/DefaultValue.php

File

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

Class

DefaultValue
Plugin to select from the list of fields.

Namespace

Drupal\pardot\Plugin\PardotFormMapFormatterPlugin

Code

public function getContactFormFieldCollection() {
  $fields = [];
  $entity_id = explode(':', $this->configuration['entity_id'])[1] ?? '';
  $allowed_types = $this->configuration['allowed_field_types'] ?? [];
  $field_definitions = $this->entityFieldManager
    ->getFieldDefinitions('contact_message', $entity_id);
  foreach ($field_definitions as $field_name => $field_definition) {
    $i = in_array($field_definition
      ->getType(), $allowed_types);
    $k = $field_definition
      ->getType();
    if ($allowed_types && in_array($field_definition
      ->getType(), $allowed_types)) {
      $fields[$field_name] = (string) $field_definition
        ->getLabel();
    }
    elseif (!$allowed_types) {
      $fields[$field_name] = (string) $field_definition
        ->getLabel();
    }
  }
  return $fields;
}