Hi all,

If someone can advise me how to do this within my own module I would be happy to but despite having experience with hook_form_alter to modify forms in the past I cannot get this to work with this module. My users have complained that the roles fieldset (per_role) which is displayed first and expanded by default is too big. They do not deal with granting permissions to a given node by role but instead focus on granting permissions on a user by user basis. I have this set up with ACL and user based permissions are working fine but I cannot find a way to collapse or revoke the display of the role based fieldset no matter what I try. In my own module (called submission_helper) I tried the following:

function submission_helper_form_alter(&$form, &$form_state, $form_id) {
 
  switch($form_id) {
    
  // The content_access_page form is used by the access control module to grant rights for individual nodes.
  case 'content_access_page' :
      
    
    // Hide the role based fieldset
    $form['per-role']['#access'] = false; 
    
    // Collapse the role based fieldset by default  
    //$form['per-role']['#collapsed'] = true;
    
    // Try adding additional #after_build item to handle changes above
    $form['per_role']['#after_build'][] = 'content_access_collapse_roles';
     
  break;

}

function content_access_collapse_roles($element, &$form_state) {
  
  $element['#collapsed'] = TRUE;
  return $element;
}

This code shows three different things I tried (collapsing the fieldset, hiding it, and collapsing it via #after_build function) none of these methods worked. I cannot figure out why. I have used hook_form_alter plenty of times in the past but can't get this to work. Can someone tell me what I'm doing wrong or can we make it so these fieldsets are collapsed by default?

I even tried altering my module weight so it would be guaranteed to fire last but no luck.

Comments

jaydarnell’s picture

Issue summary: View changes

Left out a minor detail

jaydarnell’s picture

Status: Active » Closed (works as designed)

Some time later I realized my code had a minor syntax error (using the key per-role not per_role) Nothing to see here. Working as intended!