0

I'm working with the Support Ticketing System module in Drupal 7. My clients would like to be able to see at a glance who is subscribed to notifications on a ticket. The Subscribed field is collapsed by default, meaning the client has to click on the Subscribed link to expand the field to see the users subscribed.

How can I change this so that the field is expanded when the page loads, and save my clients a click?

EDIT: The node is variable--when creating a new support ticket, it will be /node/add/support-ticket. After the ticket has been created, it could be anything.

But the particular fieldset I want to target will always have the id "edit-subscribed".

2
  • It's probably a quick jquery or form alter snippet away. You should mention where the display is at (e.g. node page, view page, admin page, etc.) so someone knows what to target.
    – Shawn Conn
    Commented Oct 1, 2016 at 1:31
  • Edited to add more info.
    – BHammond
    Commented Oct 3, 2016 at 16:56

1 Answer 1

2

A simple hook_form_BASE_FORM_ID_alter() invocation can alter the default properties of the form. If you inspect the form array you'll see that the fieldset is stored in $form['subscribe']['subscribed']. By setting the #collapsible element to FALSE, the or #collapsed element to FALSE (if you want to retain collapsibility), the default behavior will be to keep the fieldset open.

For example:

function MYMODULE_form_support_ticket_node_form_alter(&$form, &$form_state, $form_id) {
  // Replace #collapsible with #collapsed to retain collapsibility.
  $form['subscribe']['subscribed']['#collapsible'] = FALSE;
}
6
  • Just noting, OP may prefer to set the #collapsed property to false, to preserve the collapsable fieldset functionality. Commented Oct 4, 2016 at 11:19
  • Good suggestion, updated.
    – Shawn Conn
    Commented Oct 4, 2016 at 18:27
  • Thanks very much--This works for the support ticket form, when you are editing a support ticket. But how can I make it work when you're just viewing a support ticket, where the form being displayed is comment-form rather than support-ticket-node-form? I see how to target the form ID, but don't see the in the support ticket module where the correct element is stored.
    – BHammond
    Commented Oct 5, 2016 at 20:55
  • It's a different since it's not a form. Please that as a new question. We try to keep chatter to a minimum and focus on 1 question per post to make it more utilizable as a knowledge base.
    – Shawn Conn
    Commented Oct 6, 2016 at 4:58
  • Okay, will do. Thanks for the very helpful advice (on the hook, and on posting etiquette).
    – BHammond
    Commented Oct 7, 2016 at 17:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.