0
我正在從Drupal示例文件創建一個嚮導,並且想要重構設置選項和無線電等項目時重複的代碼段。drupal 7.如何重構表單數組
我已經嘗試了一個簡單的函數傳遞「普通」和「優先」,但無法找到一種方法使其工作。
有人可以給我一個這樣做的最佳方法的想法嗎?
無分裂代碼如下:
function services_wizard_share_capital_classes($form, &$form_state) {
$form['share_classes']['type_of_class'] = array(
'#type' => 'select',
'#title' => t('What type of share will this class be?'),
'#options' => array(
1 => t('Ordinary'),
2 => t('Preferential'),
),
);
$form['ordinary']['share_type'] = array(
'#type' => 'item',
'#description' => t("You chose Ordinary Shares"),
'#states' => array(
'visible' => array(
':input[name="type_of_class"]' => array('value' => '1'),
),
),
);
$form['preferential']['share_type'] = array(
'#type' => 'item',
'#description' => t("You chose Preferential Shares"),
'#states' => array(
'visible' => array(
':input[name="type_of_class"]' => array('value' => '2'),
),
),
);
return $form;
}
非常感謝,那就是訣竅。 –