more patches from Peter: more linking and improvement of examples. thanks :)

This commit is contained in:
nlopess
2005-05-25 19:13:20 +00:00
parent a35971406b
commit b84a9d2d46
54 changed files with 838 additions and 515 deletions

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision$ -->
<sect1 id="language.function.html.checkboxes">
<title>html_checkboxes</title>
<title>{html_checkboxes}</title>
<informaltable frame="all">
<tgroup cols="5">
<colspec colname="param" align="center" />
@@ -72,7 +72,9 @@
</tgroup>
</informaltable>
<para>
html_checkboxes is a custom function that creates an html checkbox
{html_checkboxes} is a
<link linkend="language.custom.functions">custom function</link>
that creates an html checkbox
group with provided data. It takes care of which item(s) are
selected by default as well. Required attributes are values and
output, unless you use options instead. All output is XHTML
@@ -83,30 +85,29 @@
name/value-pairs inside each of the created &lt;input&gt;-tags.
</para>
<example>
<title>html_checkboxes</title>
<para>
where PHP code is:
</para>
<title>{html_checkboxes}</title>
<programlisting role="php">
<![CDATA[
<?php
require('Smarty.class.php');
$smarty = new Smarty;
$smarty->assign('cust_ids', array(1000,1001,1002,1003));
$smarty->assign('cust_names', array('Joe Schmoe','Jack Smith','Jane Johnson','Charlie Brown'));
$smarty->assign('cust_names', array(
'Joe Schmoe',
'Jack Smith',
'Jane Johnson',
'Charlie Brown'));
$smarty->assign('customer_id', 1001);
$smarty->display('index.tpl');
?>
]]>
</programlisting>
<para>
and index.tpl is:
where template is
</para>
<programlisting>
<![CDATA[
{html_checkboxes name="id" values=$cust_ids selected=$customer_id output=$cust_names separator="<br />"}
{html_checkboxes name="id" values=$cust_ids output=$cust_names
selected=$customer_id separator="<br />"}
]]>
</programlisting>
<para>
@@ -116,20 +117,18 @@ $smarty->display('index.tpl');
<![CDATA[
<?php
require('Smarty.class.php');
$smarty = new Smarty;
$smarty->assign('cust_checkboxes', array(
1000 => 'Joe Schmoe',
1001 => 'Jack Smith',
1002 => 'Jane Johnson',
1003 => 'Charlie Brown'));
$smarty->assign('customer_id', 1001);
$smarty->display('index.tpl');
?>
]]>
</programlisting>
<para>
and index.tpl is:
and the template is
</para>
<programlisting>
<![CDATA[
@@ -142,12 +141,42 @@ $smarty->display('index.tpl');
<screen>
<![CDATA[
<label><input type="checkbox" name="id[]" value="1000" />Joe Schmoe</label><br />
<label><input type="checkbox" name="id[]" value="1001" checked="checked" />Jack Smith</label><br />
<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>
</example>
<example>
<title>
Database example (eg PEAR or 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 * from contacts where contact_id=12';
$smarty->assign('contact',$db->getRow($sql));
?>
]]>
</programlisting>
<programlisting>
<![CDATA[
{html_checkboxes name="type" options=$types selected=$contact.type_id separator="<br />"}
]]>
</programlisting>
</example>
<para>
See also
<link linkend="language.function.html.radios">{html_radios}</link>
and
<link linkend="language.function.html.options">{html_options}</link>
</para>
</sect1>
<!-- Keep this comment at the end of the file
Local variables:
@@ -169,3 +198,6 @@ vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->