I would like to be able to hide fieldgroups, vertical tabs, etc.. for forms where a user has insufficient access to view/edit/update a given field. This is particularly useful for placing administrative or role specific groups into a single group. If the user should not see the contents of the group, resulting in a fieldless group, then keep the user-interface as clean and as simple as possible by not showing that group.
I can see a use case for always showing a field group as well, such as wanting to always show the description of a given field group.
This is a feature request to do this conditionally.
That is, a user creating a given field group should be able to select a checkbox, such as "Show even if no fields are visible".
Issue fork field_group-1319942
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #1
Stalski CreditAttribution: Stalski commentedI don't see any real life case in here. And if it would be one, I can't imagine that it's common. Currently when no allowed fields are shown, the wrapping field_group will not be shown. So your request is that a group "prohibited content" needs to shown for a user who does not have access to a textarea?
I also don't know what you mean by "a user creating a given field group"? Most of the time this is the admin(istrator) job, no?
Maybe you can explain best with your real life example.
Comment #2
thekevinday CreditAttribution: thekevinday commented"That is, a user creating a given field group should be able to select a checkbox, such as "Show even if no fields are visible"."
Is simply a restatement of the request.
I would like to have a checkbox in the administration interface to enable or disable showing of a given field group when that group has no visible content.
Example form fields:
- [field: title] (access = admin, users in roles A, B, C)
- [field: body] (access = admin, users in roles A, B, C)
- [field_group: Workflow (vertical tab)] (access = all)
-- [field: Workflow Property A] = (access = admin, users in role A)
-- [field: Workflow Property B] = (access = admin, users in role B)
If the user has the role A and is not an admin user, then they currently see:
- [field: title]
- [field: body]
- [field_group: Workflow (vertical tab)]
-- [field: Workflow Property A]
If the user has the role C and is not an admin user, then they currently see:
- [field: title]
- [field: body]
- [field_group: Workflow (vertical tab)]
The conditions would be that if workflow has no visible content, the user in role C should see:
- [field: title]
- [field: body]
Unfortunately (for me), I have forms that have 10->100's of fields.
Field groups are used to help structure and make sense of those fields.
Vertical tabs help simplify things, but with a large quantity of fields it still makes sense to want to trim away as many of those field groups as possible.
This should be easy if a given group has no visible fields.
Comment #3
haggan CreditAttribution: haggan commentedI am also interested in this kind of use case.
I would like to hide the field group if no field are visible.
Comment #4
jrochate CreditAttribution: jrochate commentedI also agree with OP:
The default behavior would be what the module does: hidden when no content.
But that situation could be overridden with such condition (suggested OP checkbox)
Comment #5
giorgio79 CreditAttribution: giorgio79 commentedLooks like this was a problem in the old CCK d6 as well #277101: Hide Group when all fields empty
I am using http://drupal.org/project/field_permissions and created an Admin group for admin only fields. Now, non admins can see an empty admin group.
Comment #6
WorldFallz CreditAttribution: WorldFallz commentedthis is actually exactly the opposite issue-- that the field group should show when the user doesn't have access to the fields. Also, i just tested this with field_group-7.x-dev and the field group doesn't show when the user doesn't see any of the fields.
Comment #7
ezman CreditAttribution: ezman commentedI've found it would be useful to have the option to display empty field groups.
While building a multi-user site with heavily customised node add/edit forms, I've tried to use Field Group to place an empty div element in the form (for use as a preview area which updates with AJAX when a node is added to an Entity Reference field), so that my javascript has something that it can refer to with a single clean class name, rather than traversing nodes and using jQuery.find().
Of course it's nothing that I haven't been able to work around with form API hooks, but it would be nice to have a checkbox to allow showing empty field groups.
Comment #8
james.williams CreditAttribution: james.williams at ComputerMinds commentedDuplicate of #1482958: Allow field_group with empty fields to be displayed via setting.