public function guessChoiceLabelFromClass($entity)
    {
        $metadata = $this->metadataFactory->getClassMetadata($entity)->getMetadata();
        foreach ($metadata[0]->fieldMappings as $fieldName => $field) {
            if ($field['type'] == 'string') {
                return $fieldName;
            }
        }
        //if no string field found, return id
        return 'id';
    }
public function guessChoiceLabelFromClass($entity)
    {
        $metadata = $this->metadataFactory->getClassMetadata($entity)->getMetadata();
        foreach ($metadata[0]->fieldMappings as $fieldName => $field) {
            if ($field['type'] == 'string') {
                return $fieldName;
            }
        }
        //if no string field found, return id
        return 'id';
    }
public function guessChoiceLabelFromClass ( $ entity ) { $ metadata = $ this -> metadataFactory -> getClassMetadata ( $ entity ) -> getMetadata ( ) ; foreach ( $ metadata [ 0 ] -> fieldMappings as $ fieldName => $ field ) { if ( $ field [ 'type' ] == 'string' ) { return $ fieldName ; } } //if no string field found, return id return 'id' ; }
Trying to find string field in relation entity.
@param type $entity
@return string
Trying to find string field in relation entity .