void HTML_QuickForm_hierselect::setOptions (
array $options
)
hierselect 内の select 要素の選択肢を設定します。実際に表示される選択肢の数は、 この関数に渡された配列の要素数によって決まることに注意しましょう。
$options
要素の選択肢の配列。次のような形式になります。
後に続く要素の選択肢には、ひとつ前の要素のすべての選択肢に対応する要素が含まれなければなりません。 選択肢のない select は HTML として無効な形式であり、hierselect の JavaScript が動作しなくなります。 Bug #5218 も参照ください。
例外はスローされません。
This function can not be called statically.
since 3.2.2
hierselect の選択肢の設定
<?php
$select1 = $select2 = $select3 = array();
$select1[0] = 'Pop';
$select1[1] = 'Classical';
$select1[2] = 'Funeral doom';
// 2 つめの select
$select2[0][0] = '--- Artist ---';
$select2[0][1] = 'Red Hot Chil Peppers';
$select2[0][2] = 'The Pixies';
$select2[1][0] = '--- Artist ---';
$select2[1][1] = 'Wagner';
$select2[1][2] = 'Strauss';
$select2[2][0] = '--- Artist ---';
$select2[2][1] = 'Pantheist';
$select2[2][2] = 'Skepticism';
// 3 つめの select では CD の価格を選択します
$select3[0][0][0] = '--- Choose the artist ---';
$select3[0][1][0] = '15.00$';
$select3[0][2][1] = '17.00$';
$select3[1][0][0] = '--- Choose the artist ---';
$select3[1][1][0] = '15.00$';
$select3[1][2][1] = '17.00$';
$select3[2][0][0] = '--- Choose the artist ---';
$select3[2][1][0] = '15.00$';
$select3[2][2][1] = '17.00$';
// 要素を作成します
$sel =& $form->addElement('hierselect', 'cds', 'Choose CD:');
// そして選択肢を追加します
$sel->setOptions(array($select1, $select2, $select3));
?>