Disable dropbox by role


Can i ‘disable’ or ‘readonly’ a combobox or some options inside combobox?

I want to block this funcionality by role.


First you have to decide if you can do this with some simple client-side javascript hiding and showing, or if it has to be server-side (or a more elaborate client-side AJAX thing).

The main concern is if the restrictions involve security issues, then you can’t have the content in the HTML, even if it’s hidden on screen.

You can do this upgrade safe, server-side in an after_retrieve logic hook that change the contents of the dropdown list.

Just write some code that change the contents of global variable app_list_strings ‘dropdown_name’ key based on the role(s) of the current user.

But make sure you only do this if the current action is the EditView of the specific module, so that all values display correctly in the DetailView and in other modules.

This gets asked a lot, it would be nice to get a working example of this. I like the approach Marnus suggests.

We could make a nice Technical Blog post with this for the Docs site…