Currently the subscriptions table of checkboxes will skip over table rows if #access is not TRUE for that group of checkboxes, however it doesn't take into account #access in the individual checkbox elements within the groups.

So if I make a custom module that restricts specific checkboxes then it doesn't work properly.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rooby’s picture

Category: Feature request » Bug report
Issue summary: View changes

Actually technically this is a bug because #access is pert of the drupal core form API so it really should be supported.

rooby’s picture

Status: Active » Needs review
FileSize
1.24 KB

Here's a patch that helps for me. I have only tested my use cases so far but it should work for all use cases.

salvis’s picture

Please post a screenshot of what you're trying to accomplish.

Have you considered using #disabled rather than #access?

salvis’s picture

Status: Needs review » Postponed (maintainer needs more info)
rooby’s picture

Status: Postponed (maintainer needs more info) » Needs work

Actually I found a problem with that patch.

When I upload a new one I'll also address your previous questions.

rooby’s picture

Assigned: Unassigned » rooby
rooby’s picture

Status: Needs work » Needs review
FileSize
2.77 KB

I have a module that overrides the subscribe form in certain cases and restricts access to certain subscribe options.
For example, I might want to restrict access to subscribing to comments at the node type level but not the node level or something along those lines.

In terms of the form API this is a valid thing to do but currently this isn't possible due to the way the subscriptions table theme function handles #access.

#disabled != #access

Here is an updated version of the patch that adds the ability to restrict access at the cell level and properly handles:

  • Non-empty rows with empty cells: Empty cells are printed in their place to avoid column count mismatches between rows.
  • Empty rows: Empty rows are excluded from the table all together.
  • Empty columns: Empty columns are excluded from the table all together.
salvis’s picture

Status: Needs review » Needs work
+++ b/subscriptions_ui.module
@@ -279,25 +279,61 @@ function subscriptions_ui_theme() {
-  $col_indexes = array_keys($headers);
-  unset($headers[end($col_indexes)]['width']);
+  if (isset($headers[end($col_indexes)]['width'])) {
+    unset($headers[end($col_indexes)]['width']);
+  }
+

This is not doing what you think it is, because your $col_indexes are not column indexes (IOW, your name of the variable is bad!). Your condition is never true and your 'if' only hides the bug.