Form/DataTransformer/CustomFieldsGroupToIdTransformer.php
public function reverseTransform($id)
    {
        if (!$id) {
            return null;
        }
        
        if ($id instanceof CustomFieldsGroup) {
            throw new TransformationFailedException(sprintf(
                  'The transformation failed: the expected argument on '
                  . 'reverseTransform is an object of type int,'
                  . 'Chill\CustomFieldsBundle\Entity\CustomFieldsGroup, '
                  . 'given', gettype($id)));
        }

        $customFieldsGroup = $this->om
            ->getRepository('ChillCustomFieldsBundle:customFieldsGroup')->find($id)
        ;

        if (null === $customFieldsGroup) {
            throw new TransformationFailedException(sprintf(
                'Le group avec le numéro "%s" ne peut pas être trouvé!',
                $id
            ));
        }

        return $customFieldsGroup;
    }
public function reverseTransform($id)
    {
        if (!$id) {
            return null;
        }
        
        if ($id instanceof CustomFieldsGroup) {
            throw new TransformationFailedException(sprintf(
                  'The transformation failed: the expected argument on '
                  . 'reverseTransform is an object of type int,'
                  . 'Chill\CustomFieldsBundle\Entity\CustomFieldsGroup, '
                  . 'given', gettype($id)));
        }

        $customFieldsGroup = $this->om
            ->getRepository('ChillCustomFieldsBundle:customFieldsGroup')->find($id)
        ;

        if (null === $customFieldsGroup) {
            throw new TransformationFailedException(sprintf(
                'Le group avec le numéro "%s" ne peut pas être trouvé!',
                $id
            ));
        }

        return $customFieldsGroup;
    }
Transforms a string (id) to an object (CustomFieldsGroup).

@param  string $id
@return CustomFieldsGroup|null
@throws TransformationFailedException if object (report) is not found.