protected function buildFormOptions($name, array $field, $data = null)
    {
        // Allow sub options structure (collection case)
        if (isset($field['options']['constraints'])) {
            $field['options']['options'] = $this->buildFormOptions('', $field['options']);
        }

        $constraints = array();
        foreach ($field['constraints'] as $constraint) {
            $constraints[] = $this->buildConstraint($constraint);
        }

        $field['options']['constraints'] = $constraints;

        if (null !== $data && isset($data[$name])) {
            $field['options']['data'] = $data[$name];
        }

        return $field['options'];
    }