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

224 lines
6.3 KiB
XML
Raw Normal View History

2004-04-13 15:43:47 +00:00
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision$ -->
2006-05-22 08:46:06 +00:00
<!-- EN-Revision: 1.16 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.checkboxes">
2005-12-04 17:56:06 +00:00
<title>{html_checkboxes}</title>
<para>
{html_checkboxes} est une
<link linkend="language.custom.functions">fonction utilisateur</link>
qui cr<63>e un groupe de cases <20> cocher avec les donn<6E>es fournies. Elle prend
en compte la liste des <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.
2006-03-22 17:30:04 +00:00
La sortie g<>n<EFBFBD>r<EFBFBD>e est conforme au XHTML.
2005-12-04 17:56:06 +00:00
</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>checkbox</emphasis></entry>
<entry>Nom de la liste de cases <20> cocher</entry>
</row>
<row>
<entry>values</entry>
<entry>array</entry>
<entry>Oui, <20> moins que vous n'utilisiez l'attribut
option</entry>
<entry><emphasis>n/a</emphasis></entry>
<entry>Un tableau de valeurs pour les cases <20>
cocher</entry>
</row>
<row>
<entry>output</entry>
<entry>array</entry>
<entry>Oui, <20> moins que vous n'utilisiez l'attribut
option</entry>
<entry><emphasis>n/a</emphasis></entry>
<entry>Un tableau de sortie pour les cases <20> cocher</entry>
</row>
<row>
2004-11-01 17:47:43 +00:00
<entry>selected</entry>
2004-11-01 17:34:01 +00:00
<entry>cha<EFBFBD>ne de caract<63>res/tableau</entry>
2004-05-23 15:50:53 +00:00
<entry>Non</entry>
<entry><emphasis>empty</emphasis></entry>
<entry>Les <20>l<EFBFBD>ments coch<63>s de la liste</entry>
</row>
<row>
<entry>options</entry>
2004-11-01 17:34:01 +00:00
<entry>Tableau associatif</entry>
2004-05-23 15:50:53 +00:00
<entry>Oui, <20> moins que vous n'utilisiez values et
output</entry>
<entry><emphasis>n/a</emphasis></entry>
<entry>Un tableau associatif de valeurs et
sorties</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 caract<63>re pour s<>parer chaque case
<20> cocher</entry>
2006-05-22 08:46:06 +00:00
</row>
<row>
<entry>assign</entry>
<entry>cha<EFBFBD>ne de caract<63>res</entry>
<entry>Non</entry>
<entry><emphasis>empty</emphasis></entry>
<entry>Assigne les balises d'un checkbox <20> un tableau plut<75>t que de les afficher</entry>
2004-05-23 15:50:53 +00:00
</row>
<row>
<entry>labels</entry>
<entry>bool<EFBFBD>en</entry>
<entry>Non</entry>
<entry><emphasis>true</emphasis></entry>
2004-07-02 22:30:34 +00:00
<entry>ajoute la balise &lt;label&gt;- <20> la sortie</entry>
</row>
2006-03-22 17:30:04 +00:00
<row>
<entry>assign</entry>
<entry>cha<EFBFBD>ne de caract<63>res</entry>
<entry>Non</entry>
<entry><emphasis>empty</emphasis></entry>
<entry>assigne la sortie <20> un tableau dont chaque checkbox est un <20>l<EFBFBD>ment.</entry>
</row>
2004-05-23 15:50:53 +00:00
</tbody>
</tgroup>
</informaltable>
<para>
Tous les param<61>tres qui ne sont pas list<73>s ci-dessus sont affich<63>s
en tant que paires nom/valeur dans chaque balise &lt;input&gt; cr<63>e.
</para>
<example>
2005-12-04 17:56:06 +00:00
<title>{html_checkboxes}</title>
<programlisting role="php">
<![CDATA[
<?php
2005-12-04 17:56:06 +00:00
$smarty->assign('cust_ids', array(1000,1001,1002,1003));
2005-12-04 17:56:06 +00:00
$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-09 16:45:23 +00:00
]]>
2005-05-11 09:47:36 +00:00
</programlisting>
<para>
2005-12-04 17:56:06 +00:00
o<> index.tpl est :
</para>
<programlisting>
<![CDATA[
2006-03-22 17:30:04 +00:00
{html_checkboxes name='id' values=$cust_ids output=$cust_names
selected=$customer_id separator='<br />'}
2005-05-09 16:45:23 +00:00
]]>
</programlisting>
2005-05-09 16:45:23 +00:00
<para>
ou bien, le code PHP est :
</para>
<programlisting role="php">
<![CDATA[
<?php
2004-04-13 15:43:47 +00:00
$smarty->assign('cust_checkboxes', 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);
2005-12-04 17:56:06 +00:00
?>
]]>
</programlisting>
<para>
2005-12-04 17:56:06 +00:00
et index.tpl est :
</para>
<programlisting>
<![CDATA[
2006-03-22 17:30:04 +00:00
{html_checkboxes name='id' options=$cust_checkboxes
selected=$customer_id separator='<br />'}
]]>
</programlisting>
<para>
Les deux examples donnent <20> l'<27>cran :
</para>
<screen>
<![CDATA[
<label><input type="checkbox" name="id[]" value="1000" />Joe Schmoe</label><br />
2005-12-04 17:56:06 +00:00
<label><input type="checkbox" name="id[]" value="1001" checked="checked" />Jack Smith</label>
<br />
<label><input type="checkbox" name="id[]" value="1002" />Jane Johnson</label><br />
<label><input type="checkbox" name="id[]" value="1003" />Charlie Brown</label><br />
]]>
</screen>
2004-05-23 15:50:53 +00:00
</example>
2005-12-04 17:56:06 +00:00
<example>
<title>
Exemple avec une base de donn<6E>es (eg PEAR ou ADODB) :
</title>
<programlisting role="php">
<![CDATA[
<?php
2006-03-22 17:30:04 +00:00
$sql = 'select type_id, types from contact_types order by type';
$smarty->assign('contact_types',$db->getAssoc($sql));
2005-12-04 17:56:06 +00:00
2006-03-22 17:30:04 +00:00
$sql = 'select contact_id, contact_type, contact from contacts where contact_id=12';
2005-12-04 17:56:06 +00:00
$smarty->assign('contact',$db->getRow($sql));
?>
]]>
</programlisting>
<programlisting>
<![CDATA[
{html_checkboxes name="type" options=$types selected=$contact.type_id separator="<br />"}
]]>
</programlisting>
</example>
<para>
Voir aussi
<link linkend="language.function.html.radios">{html_radios}</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
-->