开发者

Theming Drupal Add Block form via forms API

Can anyone advise me on customising the Add Block form? (/admin/build/block/add)

I want to hide the "User specific visib开发者_运维百科ility settings" and "Role specific visibility settings" from users. This is what i've got so far, but obviously it's not right and I can't figure out what the array is. Anyone got the experience on this?

function theme_add_block_form($form) {
    $form['roles']['#prefix'] = '<div class="hidden">';
    $form['roles']['#suffix'] = '</div>';
    return drupal_render($form);
}

Thanks, H

EDIT - perhaps I wasn't clear - I'm comforable using the various form hooks from the API, but my problem in this case is that I can't identify the array elements to use in my function. The devel module doesn't seem to act on the blocks page, and the themer popup block thing is less than clear.


In modules/block/block.admin.inc, function block_admin_configure:

$form['user_vis_settings'] = array(
    '#type' => 'fieldset',
    '#title' => t('User specific visibility settings'),
    '#collapsible' => TRUE,
  );

(...)

$form['role_vis_settings'] = array(
    '#type' => 'fieldset',
    '#title' => t('Role specific visibility settings'),
    '#collapsible' => TRUE,
  );

Just try to hide $form['user_vis_settings'] and $form['role_vis_settings'].

EDIT:

Don't touch modules/block/block.admin.inc!! (I only was pointing where I found the form fields' names ). Hide the fields in your theme_add_block_form. Instead of wrapping the fields inside a div, you can write $form['user_vis_settings']['#access'] = false;


http://api.drupal.org/api/function/hook_form_alter/6


This is the way to go. Using the http://api.drupal.org/api/function/hook_form_alter/6 as say in an other answer. You need to write this code in a costum module.

<?php   
 function module_name_form_alter(&$form, $form_state, $form_id) {
      if ($form_id == 'block_admin_configure') {
       $form['user_vis_settings'] = array(
        '#type' => 'fieldset',
        '#title' => t('User specific visibility settings'),
        '#collapsible' => TRUE,
        '#access' = FALSE,
       );
       $form['role_vis_settings'] = array(
        '#type' => 'fieldset',
        '#title' => t('Role specific visibility settings'),
        '#collapsible' => TRUE,
        '#access' = FALSE,
       );
      }
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜