MKhalidJunaid / Sonata-admin-user-friendly-view-for-security-roles

8 stars 3 forks source link

No longer working since Symfony's FQCN form names #3

Open Nepoh opened 8 years ago

Nepoh commented 8 years ago

Nice idea. But since form types are referenced by their FQCN now, overriding the form type service is no longer possible in new versions of Symfony. A form type extension must be created instead (see Symfony docs). While only minor changes are necessary to solve this issue, the huge bug #2 still occures...

spacetraveller commented 8 years ago

Any chance of forking the fix you used for this ? This is really useful I think.

spacetraveller commented 7 years ago

Ok I managed to find a solution after two days, I renamed the service to somethingelse_security_roles instead of sonata_security_roles. This works in Symfony 2.8

Change the service name in the getName() function in SecurityRolesType.php .

In admin.xml set the form.type parameter in the tags to the new service name, and set the form type in your admin page to the new service name. There is very little documentation on this, but this is the part that stumped me, you need to change the name of the template file to contain the new prefix in the block, otherwise Sonata will default to using it's built in check box type and it won't find the correct template file.

{% block new_prefix_security_roles_widget %}

This worked. If this works for you please give me kudos! Thanks!

spacetraveller commented 7 years ago

It's not correct that this won't work with Symfony 2.8, I just got it working. Another change you might want to make to Sonata Admin's settings is to turn "use_icheck" to false in the sonata_admin configs in config.xml - otherwise the plugin JS won't work when you select the group permission checkboxes.