Drupal 7 - 根据内容数据隐藏内容编辑表单的某些表单域 [英] Drupal 7 - Hide certain form fields of a content edit form depending on the content data

查看:156
本文介绍了Drupal 7 - 根据内容数据隐藏内容编辑表单的某些表单域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Drupal 7中,有没有办法根据某些内容更改内容类型的标准编辑表单?

In Drupal 7, is there a way to change the standard edit form for a content type based on a certain content?

例如:

我有一个包含复选框的内容类型...一旦检查并保存表单,我不希望此复选框可见...因此,基于复选框值在数据库中,我想要在显示表单时隐藏表单字段。

I have a content type with a checkbox...once it it checked and the form is saved, I do not want this checkbox to be visible anymore...therefore based on the checkboxes value in the Database I want to hide form fields when showing the form.

我正在建立一个小型具体的项目网站,公司想要添加项目,他们的客户是应该遵循某些步骤(上传一些内容,提供信息等),并且还应该能够检查某些要求,一旦这些要求被检查,它们就不可见/可编辑。

I am building a small specific project site, where a company wants to add projects, and their customers are supposed to follow certain steps (upload some content, provide information etc.), and also should be able to check off certain requirements, and once these are checked off, they should not be visible/editable to them.

另外,显示的表单字段应该取决于用户的角色,然后根据内容的数据库条目进行限制。

Also the displayed form fields should depend on an user's role, and then FURTHER be limited depending on the content's database entries.

是否有一个模块,可以实现这个行为? 规则和领域/权限接近我所需要的,但还不够。还是我根本没想到根据条件更改表单域的可访问性的选项?

Is there a module, which could achieve this behaviour? "rules" and "field/permissions" come close to what I need, but are not sufficient. Or did I just miss the option to change a form field's accessibility based on conditions?

我需要的是定义一个逻辑如IF(VALUEOF(CHECKBOX_1) == TRUE)那么DO_NOT_SHOW(CHECKBOX_1)

What I need is some place to define a logic like "IF (VALUEOF(CHECKBOX_1) == TRUE) THEN DO_NOT_SHOW(CHECKBOX_1)"

推荐答案

function your_module_form_alter(&$form, &$form_state, $form_id){

    switch($form_id) {
    case 'nameOfTheNode_node_form':
        //your code here. check the value from from_state.
    break;
    }
}

这篇关于Drupal 7 - 根据内容数据隐藏内容编辑表单的某些表单域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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