previousconstructor HTML_QuickForm_hierselect() (Previous) (Next) HTML_QuickForm_hierselect::setMainOptions()next

View this page in Last updated: Sun, 18 Oct 2009
English | Brazilian Portuguese | Chinese | Dutch | French | German | Hungarian | Japanese | Polish | Russian | Spanish | Turkish

HTML_QuickForm_hierselect::setOptions()

HTML_QuickForm_hierselect::setOptions() – Définit les options pour les éléments SELECT

Synopsis

require_once 'HTML/QuickForm/hierselect.php';

void HTML_QuickForm_hierselect::setOptions ( array $options )

Description

Définit les options pour les éléments SELECT. Notez que le nombre de SELECT qui sera affiché dépend du nombre d'éléments dans le tableau passé à cette méthode.

Parameter

array $options

Tableau d'options pour les éléments, possédant la structure suivante :


array(
    // options pour le premier élément
    array(
    'key_1' => 'value 1',
    'key_2' => 'value 2',
    ...
    'key_N' => 'value N',
    ),
    // options pour le second élément
    array(
    'key_1' => array(
    'key_1_1' => 'value 1.1',
    'key_1_2' => 'value 1.2',
    ...
    'key_1_M1' => 'value 1.M1'
    ),
    'key_2' => array(
    'key_2_1' => 'value 2.1',
    'key_2_2' => 'value 2.2',
    ...
    'key_2_M2' => 'value 2.M2'
    ),
    ...
    'key_N' => array(
    'key_N_1' => 'value N.1',
    'key_N_2' => 'value N.2',
    ...
    'key_N_MN' => 'value N.MN'
    )
)
// options pour les autres éléments
...
)

Note: Les options pour les sous éléments doivent avoir des clés pour toutes les options de l'élément précédent. Avoir un SELECT sans option est invalide en HTML et rompera le Javascript. Voir aussi Bug #5218.

Throws

No exceptions thrown.

Note

This function can not be called statically.

Disponible depuis la version 3.2.2.

Example

Définition des options

<?php
$select1 
$select2 $select3 = array();

$select1[0] = 'Pop';
$select1[1] = 'Classique';
$select1[2] = 'Funéraire';

// second select
$select2[0][0] = '--- Artistes ---';
$select2[0][1] = 'Red Hot Chil Peppers';
$select2[0][2] = 'The Pixies';

$select2[1][0] = '--- Artistes ---';
$select2[1][1] = 'Wagner';
$select2[1][2] = 'Strauss';

$select2[2][0] = '--- Artistes ---';
$select2[2][1] = 'Pantheist';
$select2[2][2] = 'Skepticism';

// Création d'un troisième select avec les prix des cds
$select3[0][0][0] = '--- Choisissez un artiste ---';
$select3[0][1][0] = '15.00Eur';
$select3[0][2][1] = '17.00Eur';
$select3[1][0][0] = '--- Choisissez the artiste ---';
$select3[1][1][0] = '15.00Eur';
$select3[1][2][1] = '17.00Eur';
$select3[2][0][0] = '--- Choisissez the artiste ---';
$select3[2][1][0] = '15.00Eur';
$select3[2][2][1] = '17.00Eur';

// Création de l'élément
$sel =& $form->addElement('hierselect''cds''Choisissez un CD:');

// Et ajout des options de sélection
$sel->setOptions(array($select1$select2$select3));
?>
previousconstructor HTML_QuickForm_hierselect() (Previous) (Next) HTML_QuickForm_hierselect::setMainOptions()next

Download Documentation Last updated: Sun, 18 Oct 2009
Do you think that something on this page is wrong? Please file a bug report or add a note.
User Notes:
There are no user contributed notes for this page.