通过表单 API 主题化 Drupal 添加块表单
谁能建议我定制“添加块”表单? (/admin/build/block/add)
我想对用户隐藏“用户特定的可见性设置”和“角色特定的可见性设置”。这是我到目前为止所得到的,但显然这是不正确的,我无法弄清楚数组是什么。有人有这方面的经验吗?
function theme_add_block_form($form) {
$form['roles']['#prefix'] = '<div class="hidden">';
$form['roles']['#suffix'] = '</div>';
return drupal_render($form);
}
谢谢, H
编辑 - 也许我不清楚 - 我很舒服地使用 API 中的各种表单挂钩,但在这种情况下我的问题是我无法识别要在我的函数中使用的数组元素。开发模块似乎没有在块页面上起作用,并且主题弹出块的事情也不太清楚。
Can anyone advise me on customising the Add Block form? (/admin/build/block/add)
I want to hide the "User specific visibility 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在
modules/block/block.admin.inc
中,函数block_admin_configure
:尝试隐藏
$form['user_vis_settings']
和$form['role_vis_settings']
。编辑:
不要碰
modules/block/block.admin.inc
! (我只是指出我找到表单字段名称的位置)。隐藏theme_add_block_form
中的字段。您可以编写$form['user_vis_settings']['#access'] = false; ,而不是将字段包装在 div 内
In
modules/block/block.admin.inc
, functionblock_admin_configure
: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 yourtheme_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
http://api.drupal.org/api/function/hook_form_alter/6
这是要走的路。使用 http://api.drupal.org/api/function/hook_form_alter/6< /a> 正如另一个答案中所说。您需要在 Costum 模块中编写此代码。
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.