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

查看:17
本文介绍了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) THEN 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天全站免登陆