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仍然可見。