我只需要隐藏一个fieldset元素的两个子节点中的一个。
我遇到了将#type ='hidden'值分配给字段集的2个子元素的问题。
换句话说,我有:
Array
(
[4] => Array
(
[#type] => hidden
[#title] => Distribution Product
[#default_value] => Array
(
)
[#options] => Array
(
[] => - None selected -
[0] => stdClass Object
(
[option] => Array
(
[38] => Cosmetics
)
)
[1] => stdClass Object
(
[option] => Array
(
[39] => Hair
)
)
)
[#description] =>
[#multiple] => 0
[#size] => 0
[#weight] => 0
[#theme] => taxonomy_term_select
[#required] => 0
)
[1] => Array
(
[#type] => select
[#title] => Product
[#default_value] => Array
(
[0] => 26
)
[#options] => Array
(
[] => - None selected -
[0] => stdClass Object
(
[option] => Array
(
[28] => Cosmetics
)
)
[1] => stdClass Object
(
[option] => Array
(
[26] => -Joelle Ciocco
)
)
)
[#description] =>
[#multiple] => 0
[#size] => 0
[#weight] => 0
[#theme] => taxonomy_term_select
[#required] => 0
)
[#type] => fieldset
[#title] => Vocabularies
[#collapsible] => 1
[#collapsed] =>
[#weight] => -3
[#tree] => 1
)
我现在正在分配
$form['taxonomy'][4]['#type'] = 'hidden';
$form['taxonomy'][1]['#type'] = 'hidden';
但它们都是可见的。
当然如果我隐藏
$form['taxonomy']['#type'] = 'hidden';
它有效,我隐藏了一切。
感谢
答案 0 :(得分:2)
如果你尝试
怎么办?unset($form['taxonomy'][4]);