You are here

protected function YamlFormRequest::getSourceEntityYamlFormFieldName in YAML Form 8

Get the source entity's yamlform field name.

Parameters

EntityInterface $source_entity: A form submission's source entity.

Return value

string The name of the yamlform field, or an empty string.

1 call to YamlFormRequest::getSourceEntityYamlFormFieldName()
YamlFormRequest::getCurrentSourceEntityFromQuery in src/YamlFormRequest.php
Get form submission source entity from query string.

File

src/YamlFormRequest.php, line 268

Class

YamlFormRequest
Handles form requests.

Namespace

Drupal\yamlform

Code

protected function getSourceEntityYamlFormFieldName(EntityInterface $source_entity) {
  if ($source_entity instanceof ContentEntityInterface) {
    $fields = $source_entity
      ->getFieldDefinitions();
    foreach ($fields as $field_name => $field_definition) {
      if ($field_definition
        ->getType() == 'yamlform') {
        return $field_name;
      }
    }
  }
  return '';
}