Files
smarty/docs/fr/designers/language-custom-functions/language-function-html-radios.xml

204 lines
5.7 KiB
XML
Raw Normal View History

2004-04-13 15:43:47 +00:00
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision$ -->
2006-01-28 20:51:46 +00:00
<!-- EN-Revision: 1.11 Maintainer: yannick Status: ready -->
2005-12-04 17:56:06 +00:00
2004-05-23 15:50:53 +00:00
<sect1 id="language.function.html.radios">
2005-12-04 17:56:06 +00:00
<title>{html_radios}</title>
<para>
{html_radio} est une
<link linkend="language.custom.functions">fonction personnalis<69>e</link>
qui cr<63>e des boutons radio html <20> partir des donn<6E>es fournies. Elle prend en
charge les <20>l<EFBFBD>ments s<>lectionn<6E>s par d<>faut. Les attributs requis sont values
et output, <20> moins que vous n'utilisiez options <20> la place. La sortie g<>n<EFBFBD>r<EFBFBD>e est
compatible XHTML.
</para>
2004-05-23 15:50:53 +00:00
<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>name</entry>
<entry>cha<EFBFBD>ne de caract<63>res</entry>
<entry>Non</entry>
<entry><emphasis>radio</emphasis></entry>
<entry>nom de la liste boutons radio</entry>
</row>
<row>
<entry>values</entry>
<entry>tableau</entry>
<entry>Oui, <20> moins que vous n'utilisiez l'attribut
options</entry>
<entry><emphasis>n/a</emphasis></entry>
<entry>Le tableau des valeurs des boutons radio</entry>
</row>
<row>
<entry>output</entry>
<entry>tableau</entry>
<entry>Oui, <20> moins que vous n'utilisiez l'attribut
options</entry>
<entry><emphasis>n/a</emphasis></entry>
<entry>Un tableau de libell<6C>s pour les boutons radio</entry>
</row>
<row>
<entry>checked</entry>
<entry>cha<EFBFBD>ne de caract<63>res</entry>
<entry>Non</entry>
<entry><emphasis>empty</emphasis></entry>
<entry>Les boutons radios s<>lectionn<6E>s</entry>
</row>
<row>
<entry>options</entry>
<entry>tableau associatif</entry>
<entry>Oui, <20> moins que vous n'utilisiez values
et outputs</entry>
<entry><emphasis>n/a</emphasis></entry>
<entry>un tableau associatif valeurs / libell<6C>s</entry>
</row>
<row>
<entry>separator</entry>
<entry>cha<EFBFBD>ne de caract<63>res</entry>
<entry>Non</entry>
<entry><emphasis>empty</emphasis></entry>
<entry>cha<EFBFBD>ne de s<>paration <20> placer entre les
boutons radio</entry>
</row>
</tbody>
</tgroup>
</informaltable>
<para>
Tous les param<61>tres qui ne sont pas dans la liste ci dessus sont
affich<63>s en tant que paires nom / valeur dans chaque balise &lt;input&gt;
cr<63><72>e.
</para>
2005-05-11 09:47:36 +00:00
2004-05-23 15:50:53 +00:00
<example>
2005-12-04 17:56:06 +00:00
<title>{html_radios} : Exemple 1</title>
<programlisting role="php">
2005-05-11 09:47:36 +00:00
<![CDATA[
2005-12-04 17:56:06 +00:00
<?php
2004-04-13 15:43:47 +00:00
2005-12-04 17:56:06 +00:00
$smarty->assign('cust_ids', array(1000,1001,1002,1003));
$smarty->assign('cust_names', array(
'Joe Schmoe',
'Jack Smith',
'Jane Johnson',
'Charlie Brown')
);
$smarty->assign('customer_id', 1001);
?>
2004-04-13 15:43:47 +00:00
2005-05-11 09:47:36 +00:00
]]>
</programlisting>
<para>
2005-12-04 17:56:06 +00:00
O<> le template est :
2005-05-11 09:47:36 +00:00
</para>
<programlisting>
<![CDATA[
2005-12-04 17:56:06 +00:00
{html_radios name="id" values=$cust_ids output=$cust_names
selected=$customer_id separator="<br />"}
2005-05-11 09:47:36 +00:00
]]>
</programlisting>
2005-12-04 17:56:06 +00:00
</example>
<example>
<title>{html_radios} : Exemple 2</title>
2005-05-11 09:47:36 +00:00
<programlisting>
<![CDATA[
2005-12-04 17:56:06 +00:00
<?php
2004-04-13 15:43:47 +00:00
2005-05-11 09:47:36 +00:00
$smarty->assign('cust_radios', array(
2005-12-04 17:56:06 +00:00
1000 => 'Joe Schmoe',
1001 => 'Jack Smith',
1002 => 'Jane Johnson',
1003 => 'Charlie Brown'));
$smarty->assign('customer_id', 1001);
2004-04-13 15:43:47 +00:00
2005-12-04 17:56:06 +00:00
?>
2005-05-11 09:47:36 +00:00
]]>
</programlisting>
<para>
2006-01-28 20:51:46 +00:00
O<> le template est :
2005-05-11 09:47:36 +00:00
</para>
<programlisting>
<![CDATA[
2005-12-04 17:56:06 +00:00
{html_radios name="id" options=$cust_radios selected=$customer_id separator="<br />"}
2005-05-11 09:47:36 +00:00
]]>
</programlisting>
<para>
Les deux exemples ci-dessus afficheront :
</para>
<screen>
<![CDATA[
2005-12-04 17:56:06 +00:00
<label for="id_1000">
2005-12-14 22:09:58 +00:00
<input type="radio" name="id" value="1000" id="id_1000" />Joe Schmoe</label><br />
<label for="id_1001"><input type="radio" name="id" value="1001" id="id_1001" checked="checked" />Jack Smith</label><br />
<label for="id_1002"><input type="radio" name="id" value="1002" id="id_1002" />Jane Johnson</label><br />
<label for="id_1003"><input type="radio" name="id" value="1003" id="id_1003" />Charlie Brown</label><br />
2005-05-11 09:47:36 +00:00
]]>
</screen>
2004-05-23 15:50:53 +00:00
</example>
2005-12-04 17:56:06 +00:00
<example>
<title>{html_radios} - Exemple avec une base de donn<6E>es (eg PEAR ou ADODB):</title>
<programlisting role="php">
<![CDATA[
<?php
$sql = 'select type_id, types from types order by type';
$smarty->assign('types',$db->getAssoc($sql));
$sql = 'select contact_id, name, email, type_id
from contacts where contact_id='.$contact_id;
$smarty->assign('contact',$db->getRow($sql));
?>
]]>
</programlisting>
<para>
et le template :
</para>
<programlisting>
<![CDATA[
{html_radios name="type" options=$types selected=$contact.type_id separator="<br />"}
]]>
</programlisting>
</example>
<para>
Voir aussi
<link linkend="language.function.html.checkboxes">{html_checkboxes}</link> et
<link linkend="language.function.html.options">{html_options}</link>.
</para>
2004-04-13 15:43:47 +00:00
</sect1>
2005-12-04 17:56:06 +00:00
2004-04-13 15:43:47 +00:00
<!-- 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
2005-12-04 17:56:06 +00:00
-->