2008-01-22 21:04:44 +00:00
|
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
2004-04-13 08:46:28 +00:00
|
|
|
|
<!-- $Revision$ -->
|
2008-05-25 15:06:11 +00:00
|
|
|
|
<!-- EN-Revision: 0 Maintainer: freespace Status: ready -->
|
2004-04-15 16:18:37 +00:00
|
|
|
|
<sect1 id="language.function.html.checkboxes">
|
2005-12-30 15:43:38 +00:00
|
|
|
|
<title>{html_checkboxes}</title>
|
|
|
|
|
|
<para>
|
2008-01-22 21:04:44 +00:00
|
|
|
|
{html_checkboxes} является
|
|
|
|
|
|
<link linkend="language.custom.functions">пользовательской функцией</link>,
|
|
|
|
|
|
которая создает группу флажков в HTML по указанной информации.
|
|
|
|
|
|
Также она обеспечивает отметку флажков по умолчанию.
|
|
|
|
|
|
Параметры values и output являются обязательными, если не указан атрибут
|
|
|
|
|
|
options. Весь вывод идет в формате XHTML.
|
2005-12-30 15:43:38 +00:00
|
|
|
|
</para>
|
|
|
|
|
|
|
2004-04-15 16:18:37 +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>
|
2008-01-22 21:04:44 +00:00
|
|
|
|
<entry>Имя атрибута</entry>
|
|
|
|
|
|
<entry>Тип</entry>
|
|
|
|
|
|
<entry>Обязателен</entry>
|
|
|
|
|
|
<entry>По умолчанию</entry>
|
|
|
|
|
|
<entry>Описание</entry>
|
2004-04-15 16:18:37 +00:00
|
|
|
|
</row>
|
|
|
|
|
|
</thead>
|
|
|
|
|
|
<tbody>
|
|
|
|
|
|
<row>
|
|
|
|
|
|
<entry>name</entry>
|
2004-09-20 21:19:31 +00:00
|
|
|
|
<entry>string</entry>
|
2008-01-22 21:04:44 +00:00
|
|
|
|
<entry>Нет</entry>
|
2004-04-15 16:18:37 +00:00
|
|
|
|
<entry><emphasis>checkbox</emphasis></entry>
|
2008-01-22 21:04:44 +00:00
|
|
|
|
<entry>название списка флажков</entry>
|
2004-04-15 16:18:37 +00:00
|
|
|
|
</row>
|
|
|
|
|
|
<row>
|
|
|
|
|
|
<entry>values</entry>
|
2004-09-20 21:19:31 +00:00
|
|
|
|
<entry>array</entry>
|
2008-01-22 21:04:44 +00:00
|
|
|
|
<entry>Да, если не указан атрибут options</entry>
|
2004-04-15 16:18:37 +00:00
|
|
|
|
<entry><emphasis>n/a</emphasis></entry>
|
2008-01-22 21:04:44 +00:00
|
|
|
|
<entry>Массив значений для флажков</entry>
|
2004-04-15 16:18:37 +00:00
|
|
|
|
</row>
|
|
|
|
|
|
<row>
|
|
|
|
|
|
<entry>output</entry>
|
2004-09-20 21:19:31 +00:00
|
|
|
|
<entry>array</entry>
|
2008-01-22 21:04:44 +00:00
|
|
|
|
<entry>Да, если не указан атрибут options</entry>
|
2004-04-15 16:18:37 +00:00
|
|
|
|
<entry><emphasis>n/a</emphasis></entry>
|
2008-01-22 21:04:44 +00:00
|
|
|
|
<entry>массив названий флажков</entry>
|
2004-04-15 16:18:37 +00:00
|
|
|
|
</row>
|
|
|
|
|
|
<row>
|
2004-11-01 15:56:12 +00:00
|
|
|
|
<entry>selected</entry>
|
2004-09-20 21:19:31 +00:00
|
|
|
|
<entry>string/array</entry>
|
2008-01-22 21:04:44 +00:00
|
|
|
|
<entry>Нет</entry>
|
|
|
|
|
|
<entry><emphasis>пусто</emphasis></entry>
|
|
|
|
|
|
<entry>выбранный флажок(флажки)</entry>
|
2004-04-15 16:18:37 +00:00
|
|
|
|
</row>
|
|
|
|
|
|
<row>
|
|
|
|
|
|
<entry>options</entry>
|
2004-09-20 21:19:31 +00:00
|
|
|
|
<entry>associative array</entry>
|
2008-01-22 21:04:44 +00:00
|
|
|
|
<entry>Да, если не указаны атрибуты values и output</entry>
|
2004-04-15 16:18:37 +00:00
|
|
|
|
<entry><emphasis>n/a</emphasis></entry>
|
2008-01-22 21:04:44 +00:00
|
|
|
|
<entry>Ассоциативнй массив значений и названий</entry>
|
2004-04-15 16:18:37 +00:00
|
|
|
|
</row>
|
|
|
|
|
|
<row>
|
|
|
|
|
|
<entry>separator</entry>
|
2004-09-20 21:19:31 +00:00
|
|
|
|
<entry>string</entry>
|
2008-01-22 21:04:44 +00:00
|
|
|
|
<entry>Нет</entry>
|
|
|
|
|
|
<entry><emphasis>пусто</emphasis></entry>
|
|
|
|
|
|
<entry>строка разделяющая каждый флажок</entry>
|
2004-04-15 16:18:37 +00:00
|
|
|
|
</row>
|
2004-09-20 21:19:31 +00:00
|
|
|
|
<row>
|
|
|
|
|
|
<entry>labels</entry>
|
|
|
|
|
|
<entry>boolean</entry>
|
2008-01-22 21:04:44 +00:00
|
|
|
|
<entry>Нет</entry>
|
2004-09-20 21:19:31 +00:00
|
|
|
|
<entry><emphasis>true</emphasis></entry>
|
2008-01-22 21:04:44 +00:00
|
|
|
|
<entry>добавляет <label>-тэги к выводу</entry>
|
2004-09-20 21:19:31 +00:00
|
|
|
|
</row>
|
2006-07-20 11:56:09 +00:00
|
|
|
|
<row>
|
|
|
|
|
|
<entry>assign</entry>
|
|
|
|
|
|
<entry>string</entry>
|
2008-01-22 21:04:44 +00:00
|
|
|
|
<entry>Нет</entry>
|
|
|
|
|
|
<entry><emphasis>пусто</emphasis></entry>
|
|
|
|
|
|
<entry>сохранить тэги флажков в массив вместо вывода</entry>
|
2006-07-20 11:56:09 +00:00
|
|
|
|
</row>
|
2004-04-15 16:18:37 +00:00
|
|
|
|
</tbody>
|
|
|
|
|
|
</tgroup>
|
|
|
|
|
|
</informaltable>
|
2005-12-30 15:43:38 +00:00
|
|
|
|
|
2004-04-15 16:18:37 +00:00
|
|
|
|
<para>
|
2008-01-22 21:04:44 +00:00
|
|
|
|
Все параметры, которые не указаны в списке, выводятся в виде
|
|
|
|
|
|
пар name/value в каждом созданном тэге <input>.
|
2004-04-15 16:18:37 +00:00
|
|
|
|
</para>
|
|
|
|
|
|
<example>
|
2005-12-30 15:43:38 +00:00
|
|
|
|
<title>{html_checkboxes}</title>
|
2004-09-20 21:19:31 +00:00
|
|
|
|
<programlisting role="php">
|
2004-04-15 16:18:37 +00:00
|
|
|
|
<![CDATA[
|
2004-09-20 21:19:31 +00:00
|
|
|
|
<?php
|
2004-04-13 08:46:28 +00:00
|
|
|
|
|
2004-09-20 21:19:31 +00:00
|
|
|
|
$smarty->assign('cust_ids', array(1000,1001,1002,1003));
|
2005-12-30 15:43:38 +00:00
|
|
|
|
$smarty->assign('cust_names', array(
|
|
|
|
|
|
'Joe Schmoe',
|
|
|
|
|
|
'Jack Smith',
|
|
|
|
|
|
'Jane Johnson',
|
|
|
|
|
|
'Charlie Brown')
|
|
|
|
|
|
);
|
2004-09-20 21:19:31 +00:00
|
|
|
|
$smarty->assign('customer_id', 1001);
|
2004-04-13 08:46:28 +00:00
|
|
|
|
|
2004-09-20 21:19:31 +00:00
|
|
|
|
?>
|
|
|
|
|
|
]]>
|
|
|
|
|
|
</programlisting>
|
|
|
|
|
|
<para>
|
2008-01-22 21:04:44 +00:00
|
|
|
|
шаблон:
|
2004-09-20 21:19:31 +00:00
|
|
|
|
</para>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
<![CDATA[
|
2005-12-30 15:43:38 +00:00
|
|
|
|
{html_checkboxes name="id" values=$cust_ids output=$cust_names
|
|
|
|
|
|
selected=$customer_id separator="<br />"}
|
2004-09-20 21:19:31 +00:00
|
|
|
|
]]>
|
|
|
|
|
|
</programlisting>
|
2005-05-09 17:34:38 +00:00
|
|
|
|
<para>
|
2008-01-22 21:04:44 +00:00
|
|
|
|
или где PHP код:
|
2005-05-09 17:34:38 +00:00
|
|
|
|
</para>
|
2004-09-20 21:19:31 +00:00
|
|
|
|
<programlisting role="php">
|
|
|
|
|
|
<![CDATA[
|
|
|
|
|
|
<?php
|
2004-04-13 08:46:28 +00:00
|
|
|
|
|
2004-09-20 21:19:31 +00:00
|
|
|
|
require('Smarty.class.php');
|
|
|
|
|
|
$smarty = new Smarty;
|
|
|
|
|
|
$smarty->assign('cust_checkboxes', array(
|
|
|
|
|
|
1000 => 'Joe Schmoe',
|
|
|
|
|
|
1001 => 'Jack Smith',
|
|
|
|
|
|
1002 => 'Jane Johnson',
|
2005-12-30 15:43:38 +00:00
|
|
|
|
1003 => 'Charlie Brown')
|
|
|
|
|
|
);
|
2004-09-20 21:19:31 +00:00
|
|
|
|
$smarty->assign('customer_id', 1001);
|
2005-12-30 15:43:38 +00:00
|
|
|
|
|
2004-09-20 21:19:31 +00:00
|
|
|
|
?>
|
2004-04-15 16:18:37 +00:00
|
|
|
|
]]>
|
|
|
|
|
|
</programlisting>
|
2004-09-20 21:19:31 +00:00
|
|
|
|
<para>
|
2008-01-22 21:04:44 +00:00
|
|
|
|
шаблон:
|
2004-09-20 21:19:31 +00:00
|
|
|
|
</para>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
<![CDATA[
|
2004-11-01 15:56:12 +00:00
|
|
|
|
{html_checkboxes name="id" options=$cust_checkboxes selected=$customer_id separator="<br />"}
|
2004-09-20 21:19:31 +00:00
|
|
|
|
]]>
|
|
|
|
|
|
</programlisting>
|
|
|
|
|
|
<para>
|
2008-01-22 21:04:44 +00:00
|
|
|
|
оба примера выведут:
|
2004-09-20 21:19:31 +00:00
|
|
|
|
</para>
|
|
|
|
|
|
<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="1002" />Jane Johnson</label><br />
|
|
|
|
|
|
<label><input type="checkbox" name="id[]" value="1003" />Charlie Brown</label><br />
|
|
|
|
|
|
]]>
|
|
|
|
|
|
</screen>
|
2004-04-15 16:18:37 +00:00
|
|
|
|
</example>
|
2005-12-30 15:43:38 +00:00
|
|
|
|
<example>
|
|
|
|
|
|
<title>
|
2008-01-22 21:04:44 +00:00
|
|
|
|
Пример с базой данных (к примеру, PEAR или ADODB):
|
2005-12-30 15:43:38 +00:00
|
|
|
|
</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>
|
2008-01-22 21:04:44 +00:00
|
|
|
|
См. также
|
2005-12-30 15:43:38 +00:00
|
|
|
|
<link linkend="language.function.html.radios">{html_radios}</link>
|
2008-01-22 21:04:44 +00:00
|
|
|
|
и
|
2005-12-30 15:43:38 +00:00
|
|
|
|
<link linkend="language.function.html.options">{html_options}</link>
|
|
|
|
|
|
</para>
|
2004-04-13 08:46:28 +00:00
|
|
|
|
</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
|
2004-04-15 15:47:00 +00:00
|
|
|
|
-->
|