Closed sandermarechal closed 4 years ago
A ManyToOne relation means that the bar
property contains a model, not a list of models
That is what sonata_type_mode_list
does, right?. It gives you a paginatable list so you can choose one instance from it. I've started using it because some of my tables are too big to use with a sonata_type_model
, which tries to load everything in order to display a select box.
Please let me know if I have this backwards somehow.
I'm having the same issue here... have you found any workaround?
You have to generate an admin class for the entity you want to choose.
3 years later, I have the same issue here! in reply to johannes85, my "Bar" entity is Media (from sonata-media-bundle), so it already has an admin class.
Did anyone solve this?
3 years later, I have the same issue here!
Being sarcastic would not help at all.
Do you get this error with the 3.x version of this bundle? 2.x is not maintained anymore.
Hello everyone. At this point I'm having the same problem using symfony 3 and sonata admin-bundle 3. Could anyone fix this? Thank you
Hi everyone, if it can help I had the same bug on symfony4 and resolved it simply by defining the 'admin_code' like this :
$formMapper->add('lastFormResponse', ModelListType::class, [
'class' => FormResponse::class,
], [
'admin_code' => 'admin.form_response',
]);
So it seems the Admin guesser of ModelListType doesn't work with complex relations, the only difference in my code is that 'lastFormResponse' get the last occurrence in an ArrayCollection.
ModelType maybe suffer the same bug, because the select work but the add button disappear, but not sure because 'admin_code' doesn't work this time.
if your target entity is "Media" then do not forget to specify "db_driver: doctrine_orm"
in the configuration
Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
This may be related to #222.
I have a couple of entities with inheritance set up like so:
I have an Admin class that uses
setSubClasses
so I can manage all entities that extendBase
using the same Admin class:In my BaseAdmin I generate a form like this:
Now, when I create or edit an entity I get the following error:
If I use a
sonata_type_model
instead of asonata_type_model_list
then it works. Also, if I move thebar
property from My\Foo to My\Base it also works correctly. The error only appears when I use a model_list type for a relation that only exists in a subclass.