Skip to content

EntityType field type renders as entire namespace instead of just the class name #1827

Open
@DoobleD

Description

@DoobleD

When I use as a model a form type containing an EntityType field, the rendered doc shows the whole entity class namespace instead of just the class name.

In my form type:

use App\Entity\User;

...

public function buildForm(FormBuilderInterface $builder, array $options)
{
      $builder
      ->add('users', EntityType::class, [
          'class' => User::class,
          'query_builder' => function (UserRepository $repository) {
              return $repository->findAll();
          },
          'choice_value' => function ($entity = null) {
              if (is_string($entity)) return $entity;
              if ($entity instanceof User) return $entity->getEmail();
              return '';
          },
      ]);
}

Generates the following for the field in the schema description of the documentation:

users string($App\Entity\User id)

This is probably not really a bug, but I'd have expected to see:

users string($User id)

since model types otherwise have only their class names shown instead of the whole namespace. A way to show the actual id name (here email: users string($User email)) would have been great too, but that's perhaps asking too much.

I tried using model name aliases but this has no effect in that case.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions