Page 1 of 1

Enable or disable fields for different views in admin

Posted: Fri Nov 13, 2015 2:19 am
by tarun.sharma
Hi all,

i am new to broadleaf commerce.

Using @AdminPresentation, i have created a field named "Registration status" under security->user menu. But this field is also showed when i view a created user or create a new user. How can i enable "Registration status" field on user menu but it should not be shown on user view?

Thanks in advance.

Re: Enable or disable fields for different views in admin

Posted: Tue Nov 17, 2015 8:55 pm
by kunner
you can manage it by Controller.

Make your controller for a specific, and extend AdminBasicEntityController.
and override the methods.
Make sure what kind of view type you want to manage. then you could choose the method that needed to extends.

If you want to hide the field when the unauthorized user entered entityForm,
extends the method "modifyEntityForm".
(You could extends "viewEntityForm" too)

like below,

Code: Select all

@Override
protected void modifyEntityForm(EntityForm entityForm, Map<String, String> pathVars) {
    if(YOUR LOGICAL){
        Field name = entityForm.findField("fieldName");
        name.setIsVisible(false);   // set false is hiding the field
    }
}

Re: Enable or disable fields for different views in admin

Posted: Fri Nov 20, 2015 6:58 am
by tarun.sharma
@kunner Thanks a lot, this approach worked perfectly.
Also can we hide on the basis of groups? Like price group which have two fields retail price and sale price and by disabling the group we can disable all its fields.