/**
  * Retrieve the form field description given by field name.
  *
  * @param AdminInterface $admin
  * @param string         $field
  *
  * @return FormInterface
  *
  * @throws \RuntimeException
  */
 private function retrieveFormFieldDescription(AdminInterface $admin, $field)
 {
     $admin->getFormFieldDescriptions();
     $fieldDescription = $admin->getFormFieldDescription($field);
     if (!$fieldDescription) {
         throw new \RuntimeException(sprintf('The field "%s" does not exist.', $field));
     }
     if (null === $fieldDescription->getTargetEntity()) {
         throw new \RuntimeException(sprintf('No associated entity with field "%s".', $field));
     }
     return $fieldDescription;
 }
 /**
  * Retrieve the field description given by field name.
  *
  * @param AdminInterface $admin
  * @param string         $field
  *
  * @return \Symfony\Component\Form\FormInterface
  *
  * @throws \RuntimeException
  */
 private function retrieveFieldDescription(AdminInterface $admin, $field)
 {
     $admin->getFormFieldDescriptions();
     $fieldDescription = $admin->getFormFieldDescription($field);
     if (!$fieldDescription) {
         throw new \RuntimeException(sprintf('The field "%s" does not exist.', $field));
     }
     if ($fieldDescription->getType() !== 'sonata_type_model_autocomplete') {
         throw new \RuntimeException(sprintf('Unsupported form type "%s" for field "%s".', $fieldDescription->getType(), $field));
     }
     if (null === $fieldDescription->getTargetEntity()) {
         throw new \RuntimeException(sprintf('No associated entity with field "%s".', $field));
     }
     return $fieldDescription;
 }