You are here

public function YamlFormSubmissionStorage::getFieldDefinitions in YAML Form 8

Get form submission entity field definitions.

The helper method is generally used for exporting results.

Return value

array An associative array of field definition key by field name containing title, name, and datatype.

Overrides YamlFormSubmissionStorageInterface::getFieldDefinitions

See also

\Drupal\yamlform\Element\YamlFormExcludedColumns

\Drupal\yamlform\Controller\YamlFormResultsExportController

File

src/YamlFormSubmissionStorage.php, line 26

Class

YamlFormSubmissionStorage
Defines the form submission storage.

Namespace

Drupal\yamlform

Code

public function getFieldDefinitions() {

  /** @var \Drupal\Core\Field\BaseFieldDefinition[] $definitions */
  $field_definitions = $this->entityManager
    ->getBaseFieldDefinitions('yamlform_submission');

  // For now never let any see or export the serialize YAML data field.
  unset($field_definitions['data']);
  $definitions = [];
  foreach ($field_definitions as $field_name => $field_definition) {
    $definitions[$field_name] = [
      'title' => $field_definition
        ->getLabel(),
      'name' => $field_name,
      'type' => $field_definition
        ->getType(),
      'target_type' => $field_definition
        ->getSetting('target_type'),
    ];
  }
  return $definitions;
}