EasyAdminBundle icon indicating copy to clipboard operation
EasyAdminBundle copied to clipboard

Unable to save entity when doctrine enum type is not changed.

Open laytoneverson opened this issue 8 years ago • 5 comments

BUG REPORT:

  • Saving changes to an entity fails when using a doctrine Enum type.

    The enum type is rendered as a choice (dropdown). If I don't select a new value and click save the process fails with the error: The value you selected is not a valid choice.

    If I do select a new option from the dropdown and when I create a new entity the action is successful.

    I have created a custom form type and tried overriding the choices.

  • Easy Admin Version: 1.17.11, SF version 4.0.4 and php 7.1

laytoneverson avatar Feb 27 '18 00:02 laytoneverson

I don't use this EnumType, so I won't be able to help you. But I've added the help wanted label so other people from the community can help you. Thanks!

javiereguiluz avatar Mar 04 '18 10:03 javiereguiluz

Hey @laytoneverson, I have been using the enum type with the EasyAdmin bundle for a while without any issues.

All you need to do is what is described in this markdown file: https://github.com/fre5h/DoctrineEnumBundle/blob/master/Resources/docs/example_of_using.md You might also want to have a look at this: https://github.com/fre5h/DoctrineEnumBundle/issues/102#issuecomment-319901012

Happy to help you out. Any chance you could post your custom enum type and the entity property where you use it?

glaubinix avatar Mar 04 '18 20:03 glaubinix

Sure thing!

https://gist.github.com/laytoneverson/6a0b2fdb77d8c520385bce9e53e65c59

If you want to run the project there is a docker config and a pretty easy setup: https://github.com/laytoneverson/yourweb.agency

bin\build.ps1 dev
docker-compose up -d
docker-compose exec php bash
bin/console doctrine:migrations:migrate

... etc etc etc

You will have to encode a password and set it in the env and you can access the admin at /_edit_site_data

laytoneverson avatar Mar 06 '18 05:03 laytoneverson

@laytoneverson I was able to have a look at it and created a pull request in the EnumType repository. The issue is not related to the EasyAdminBundle. Therefore I think this issue can be closed.

PR can be found here: https://github.com/fre5h/DoctrineEnumBundle/pull/125

glaubinix avatar Mar 08 '18 22:03 glaubinix

@glaubinix thanks for taking care of this issue! Let's close here then. Cheers!

javiereguiluz avatar Mar 09 '18 07:03 javiereguiluz