如何在drupal中隐藏节点数据输入表单上的字段? [英] How to hide a field on node data entry form in drupal?

查看:123
本文介绍了如何在drupal中隐藏节点数据输入表单上的字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用hook_node_presave预先填充分组分类字段与组的受众值。
因此,我试图在节点数据输入表单上隐藏分类字段。我试过hook_form_alter,但是对我来说并不奏效。是否可以隐藏?

I'm using hook_node_presave to pre-populate taxonomy field with group's audience value. Thus, I'm trying to hide taxonomy field on a node data entry form. I tried hook_form_alter, but it didn't work for me. Is it possible to hide it?

推荐答案

<?php

function mymodule_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'contenttype_node_form') {
    unset($form['somefield']);
  }
}
?>

这对我来说很好。只需更改您要定位的表单字段的表单ID和键,该字段就会消失。

This works for me just fine. Just change the form id and key of the form field you are targeting, and the field should go away.

如果输入被覆盖,另一个选项将使用CSS隐藏它无论如何,无论如何。

Another option would be hiding it with CSS if the input was overridden in presave anyway.

这篇关于如何在drupal中隐藏节点数据输入表单上的字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆