1
我有由配置文件2创建的名为field_apply的复选框。然后我使用hook_form_alter来添加一个texfield,当复选框被选中时它应该是可见的。#状态不适用于配置文件2
function test_form_alter(&$form, &$form_state, $form_id) {
if($form_id == 'user_register_form') {
$form['profile_test']['test'] = array(
'#type' => 'textfield',
'#title' => 'Test text',
'#states' => array(
'visible' => array(
':input[name="field_apply"]' => array('checked' => TRUE),
),
),
);
}
}
但#states不起作用。即使未检查field_apply,Textfield仍然可见。