mirror of
https://github.com/smarty-php/smarty.git
synced 2025-10-30 03:41:36 +01:00
156 lines
4.4 KiB
XML
156 lines
4.4 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 1.1 Maintainer: nobody Status: partial -->
|
|
<sect1 id="language.function.html.options">
|
|
<title>html_options</title>
|
|
<informaltable frame="all">
|
|
<tgroup cols="5">
|
|
<colspec colname="param" align="center" />
|
|
<colspec colname="type" align="center" />
|
|
<colspec colname="required" align="center" />
|
|
<colspec colname="default" align="center" />
|
|
<colspec colname="desc" />
|
|
<thead>
|
|
<row>
|
|
<entry>Nom attribut</entry>
|
|
<entry>Type</entry>
|
|
<entry>Requis</entry>
|
|
<entry>Defaut</entry>
|
|
<entry>Description</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>values</entry>
|
|
<entry>array</entry>
|
|
<entry>Oui, à moins que vous n'utilisiez
|
|
l'attribut options</entry>
|
|
<entry><emphasis>n/a</emphasis></entry>
|
|
<entry>un tableau de valeurs pour les listes
|
|
déroulantes</entry>
|
|
</row>
|
|
<row>
|
|
<entry>output</entry>
|
|
<entry>array</entry>
|
|
<entry>Oui, à moins que vous n'utilisiez
|
|
l'attribut options</entry>
|
|
<entry><emphasis>n/a</emphasis></entry>
|
|
<entry>Un tableau de libellés pour la liste
|
|
déroulante</entry>
|
|
</row>
|
|
<row>
|
|
<entry>selected</entry>
|
|
<entry>chaîne de caractères/tableau</entry>
|
|
<entry>Non</entry>
|
|
<entry><emphasis>empty</emphasis></entry>
|
|
<entry>Les éléments sélectionnés</entry>
|
|
</row>
|
|
<row>
|
|
<entry>options</entry>
|
|
<entry>Tableau associatif</entry>
|
|
<entry>Oui, à moins que vous n'utilisiez option
|
|
et values</entry>
|
|
<entry><emphasis>n/a</emphasis></entry>
|
|
<entry>Un tableau associatif valeur / libellé</entry>
|
|
</row>
|
|
<row>
|
|
<entry>name</entry>
|
|
<entry>chaîne de caractères</entry>
|
|
<entry>Non</entry>
|
|
<entry><emphasis>empty</emphasis></entry>
|
|
<entry>Nom du goupe d'options</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
<para>
|
|
html_options est une fonction utilisateur qui crée un groupe d'options
|
|
avec les données fournies. Elle prend en charge les éléments
|
|
sélectionnés par défaut. Les attributs requis sont values et output,
|
|
à moins que vous n'utilisiez options à la place.
|
|
</para>
|
|
<para>
|
|
Si la valeur donnée est un tableau, elle sera traitée comme un
|
|
OPTGROUP html, et affichée. La récursivité est supportée avec
|
|
OPTGROUP. La sortie est compatible XHTML.
|
|
</para>
|
|
<para>
|
|
Si l'attribut optionnel <emphasis>name</emphasis> est donné, les
|
|
balises <select name="groupname"></select> entoureront la
|
|
liste d'options.
|
|
</para>
|
|
<para>
|
|
Tous les paramètres qui ne sont pas dans la liste ci-dessus sont
|
|
affichés en tant que paires nom / valeur. Ils sont ignorés si
|
|
le paramètre optionnel <emphasis>name</emphasis> n'est pas donné.
|
|
</para>
|
|
<example>
|
|
<title>html_options</title>
|
|
<programlisting>
|
|
index.php:
|
|
|
|
require('Smarty.class.php');
|
|
$smarty = new Smarty;
|
|
$smarty->assign('id_client', array(1000,1001,1002,1003));
|
|
$smarty->assign('nom_client', array('Joe Schmoe','Jack Smith','Jane
|
|
Johnson','Charlie Brown'));
|
|
$smarty->assign('client_id', 1001);
|
|
$smarty->display('index.tpl');
|
|
|
|
index.tpl:
|
|
|
|
<select name=client_id>
|
|
{html_options values=$id_client selected=$client_id output=$nom_client}
|
|
</select>
|
|
|
|
|
|
index.php:
|
|
|
|
require('Smarty.class.php');
|
|
$smarty = new Smarty;
|
|
$smarty->assign('cust_options', array(
|
|
1001 => 'Joe Schmoe',
|
|
1002 => 'Jack Smith',
|
|
1003 => 'Jane Johnson',
|
|
1004 => 'Charlie Brown'));
|
|
$smarty->assign('client_id', 1001);
|
|
$smarty->display('index.tpl');
|
|
|
|
index.tpl:
|
|
|
|
<select name=client_id>
|
|
{html_options options=$cust_options selected=$client_id}
|
|
</select>
|
|
|
|
|
|
SORTIE: (valable pour les deux exemples)
|
|
|
|
<select name=client_id>
|
|
<option value="1000">Joe Schmoe</option>
|
|
<option value="1001" selected="selected">Jack Smith</option>
|
|
<option value="1002">Jane Johnson</option>
|
|
<option value="1003">Charlie Brown</option>
|
|
</select></programlisting>
|
|
</example>
|
|
</sect1>
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"../../../../manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|