SonataAdminBundle has a powerful extensions feature which allows you to add or change features of one or more Admin instances.
I needed my extension to change some validation rules, and it turned out that imposing different validation groups was a good way to achieve it.
$formOptions attribute of Sonata\AdminBundle\Admin\AbstractAdmin class allows for setting validation groups, but I couldn’t find an easy way to modify it in my extension.
getFormBuilder method of AbstractAdmin class is where these $formOptions are added to the form builder:
So, in my admin class I override this method, to add support for extensions:
Now, in your admin extension you can add a method to actually modify $formOptions of the admin class:
I used to spend a lot of time with my grandparents in my childhood. My…
If anything is certain in this world, it is that things always change. And there…
This is the most important advice on how to be successful! Read it carefully!
WordPress has a nasty habit of storing absolute URLs in the database. That means that…
In August 2014 Google announced that their search engine will value HTTPS as a ranking…
Unix shell is one of the most powerful tools ever created, but sometimes it can…