You are here

public function MappingEditFormBase::prepareOptions in GatherContent 8.5

Same name and namespace in other branches
  1. 8.4 gathercontent_ui/src/Form/MappingEditFormBase.php \Drupal\gathercontent_ui\Form\MappingEditFormBase::prepareOptions()

Prepare options for every language for every field.

Parameters

\Cheppers\GatherContent\DataTypes\Template $template: GatherContent template object.

Return value

array Array with options.

1 call to MappingEditFormBase::prepareOptions()
MappingEditForm::submitForm in gathercontent_ui/src/Form/MappingEditForm.php
This is the default entity object builder function. It is called before any other submit handler to build the new entity object to be used by the following submit handlers. At this point of the form workflow the entity is validated and the form state…

File

gathercontent_ui/src/Form/MappingEditFormBase.php, line 273

Class

MappingEditFormBase
Class MappingEditFormBase.

Namespace

Drupal\gathercontent_ui\Form

Code

public function prepareOptions(Template $template) {
  $options = [];
  foreach ($this->entityReferenceFields as $gcMapping) {
    foreach ($gcMapping as $fieldSettings) {
      foreach ($template['related']->structure->groups as $group) {
        if ($group->id === $fieldSettings['tab']) {
          foreach ($group->fields as $field) {
            if ($field->id === $fieldSettings['name']) {
              foreach ($field->metaData->choiceFields['options'] as $option) {
                $options[$option['optionId']] = $option['label'];
              }
            }
          }
        }
      }
    }
  }
  return $options;
}