Elao / PhpEnums

:nut_and_bolt: Extended PHP 8.1+ enums features & specific integrations with frameworks and libraries
MIT License
326 stars 27 forks source link

document usage with easy admin bundle #44

Closed tristanbes closed 4 years ago

tristanbes commented 6 years ago

Hi

a section on "'how to use with easy admin" could be nice when editing entities inside easy admin bundle.

ogizanagi commented 6 years ago

Why not, PR welcomed :)

Actually it should be as easy as simply using any other form type (but as it's not a core form type, EasyAdminBundle does not provide an alias, so you have to use the FQCN).

See https://symfony.com/doc/master/bundles/EasyAdminBundle/book/edit-new-configuration.html#customize-the-form-fields

  • type (optional): the Symfony Form type used to render this field. You can use the short type name (e.g. email) instead of its fully qualified class name (e.g. Symfony\Component\Form\Extension\Core\Type\EmailType) even if your application runs on Symfony 3 (the needed conversion is done internally by the bundle). The allowed values are:
  • Any of the Symfony Form types.
  • Any of the custom EasyAdmin form types: easyadmin_autocomplete (they are explained later in this chapter).
  • type_options (optional), a hash with the options passed to the Symfony Form type used to render the field.

About the EnumType provided in this package: https://github.com/Elao/PhpEnums#symfony-form-component

bonfante commented 6 years ago

would not it be the case to have an EnumTypeGuesser?

ogizanagi commented 6 years ago

Sure. And you already opened #45 :)

But it should probably not be enough to close this issue. Showing a simple example with custom options and redirecting on the official EasyAdmin documentation still is relevant. Also, perhaps provide/showcase simple templates for list & show views rendering of enums and array of enums.

ogizanagi commented 4 years ago

Closing as there is no activity here. If anyone is willing to enhance the documentation or open a PR to improve integration with EasyAdmin, please do.