我正在尝试隐藏以嵌入式表单呈现的字段集合字段。此表单在几个不同的节点上呈现,但只有一些节点需要所有字段,所以我想将它们隐藏在不需要的节点上。
现在我正在尝试通过钩子表单更改来执行此操作,但它在字段集合中不起作用,它将在正常呈现的与集合共享字段的表单上工作。
function zenstrap_form_alter(&$form,&$form_state,$form_id){
//Form we want to target
case ($form_id==="coh_pow_node_form"):
//Appears in Normal form and Field Collection
//Hides in normal
$form['field_last_name']['#access']=FALSE;
//Appears in Normal form and Field Collection
//Hides in normal
$form['field_street']['#access']=FALSE;
//Appears in Field Collection
//Does nothing
$form['field_veteran_retired']['#access']=FALSE;
break;
}