我愿附上第7博士的具体田地清单。 这些田地有<条码>FIELD_CARDINALITY_UNLIMITED,因此,任何地方都可以从1到1。 I m 采用以下代码:
function mymodule_form_alter(&$form, &$form_state, $form_id) {
if (array_key_exists( mymodule , $form)) {
$indices = array_filter(
array_keys($form[ mymodule ][ und ]),
function($item) {
return is_numeric($item);
}
);
foreach($indices as $index) {
$form[ mymodule ][ und ][$index][ value ][ #autocomplete_path ] = api/node/title ;
}
}
}
...however, my autocomplete behavior is not being attached. I ve used the exact same code in a similar situation - the only difference is that I was adding the autocomplete to a field that had a cardinality of 1 rather than unlimited. That doesn t seem like it should change anything. I ve verified that the autocomplete is attaching by doing a debug($form[ mymodule ])
after the assignment statement, and it is definitely there. I have also debugged the exact array path I am trying to get in each iteration of the foreach loop, and it is definitely the correct form value.
EDIT:是否可以将这一问题放在一个以上模块上,使用<代码>hook_form_alter(? I m以同样的形式,以不同的模块进行与上文(但在单一领域)相同的操作。
EDIT2:我已注意到,如果我在每个通道上作假发言,我就看到汽车残值按每艘轮胎的适当价值计算。 如果我把辩论发言放在旁听器之外,汽车路就不再固定。 不管怎么说,无论是在循环过程中,还是在循环之后,都看着我的变化正在遭到破坏? 我通过将<代码>(index_0)假设为“0”,并撰写硬编码说明,附上自动填写,从而使汽车能够正确工作。 很显然,我看到以下一点:
function mymodule_form_alter(&$form, &$form_state, $form_id) {
if (array_key_exists( mymodule , $form)) {
$indices = array_filter(
array_keys($form[ mymodule ][ und ]),
function($item) {
return is_numeric($item);
}
);
foreach($indices as $index) {
$form[ mymodule ][ und ][$index][ value ][ #autocomplete_path ] = api/node/title ;
// Debug statements here show that the value #autocomplete_path is set properly
debug($form)[ mymodule ][ und ][$index][ value ]);
}
// Now, the #autocomplete_path key does not exist
debug($form)[ mymodule ][ und ][0][ value ]);
// This will make autocomplete attach correctly
$form[ mymodule ][ und ][0][ value ][ #autocomplete_path ] = api/node/title ;
}
}