mirror of
https://github.com/smarty-php/smarty.git
synced 2025-11-05 06:41:39 +01:00
152 lines
5.2 KiB
XML
152 lines
5.2 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 1.1 Maintainer: thomasgm Status: ready -->
|
|
<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>Nome do Atributo</entry>
|
|
<entry>Tipo</entry>
|
|
<entry>Obrigatório</entry>
|
|
<entry>Padrão</entry>
|
|
<entry>Descrição</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>values</entry>
|
|
<entry>array</entry>
|
|
<entry>Sim, a menos que usando atributos de options</entry>
|
|
<entry><emphasis>n/a</emphasis></entry>
|
|
<entry>uma matriz de valores para o menu dropdown</entry>
|
|
</row>
|
|
<row>
|
|
<entry>output</entry>
|
|
<entry>array</entry>
|
|
<entry>Sim, a menos que usando atributos de options</entry>
|
|
<entry><emphasis>n/a</emphasis></entry>
|
|
<entry>uma matriz de saída para o menu dropdown</entry>
|
|
</row>
|
|
<row>
|
|
<entry>selected</entry>
|
|
<entry>string/array</entry>
|
|
<entry>Não</entry>
|
|
<entry><emphasis>empty</emphasis></entry>
|
|
<entry>o elemento do options selecionado</entry>
|
|
</row>
|
|
<row>
|
|
<entry>options</entry>
|
|
<entry>associative array</entry>
|
|
<entry>Sim, a menos que usando values e output</entry>
|
|
<entry><emphasis>n/a</emphasis></entry>
|
|
<entry>uma matriz associativa de output e output</entry>
|
|
</row>
|
|
<row>
|
|
<entry>name</entry>
|
|
<entry>string</entry>
|
|
<entry>Não</entry>
|
|
<entry><emphasis>empty</emphasis></entry>
|
|
<entry>nome do grupo selecionado</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
<para>
|
|
html_options é uma função personalizada que cria um grupo html option com os dados fornecidos.
|
|
Ela está atenta de quais itens estão selecionados por padrão. Atributos obrigatórios são 'values' e
|
|
'output', a menos que você use options no lugar.
|
|
</para>
|
|
<para>
|
|
Se um valor dado é um array, ele será tratado como um OPTGROUP html,
|
|
e mostrará os grupos.
|
|
Recursividade é suportada pelo OPTGROUP. Todas as saídas são compatíveis com XHTML.
|
|
</para>
|
|
<para>
|
|
Se o atributo opcional <emphasis>name</emphasis> é dado, as tags
|
|
<select name="groupname"></select> irão incluir a lista de opções dentro dela.
|
|
Caso contrário apenas a lista de opções é gerada.
|
|
</para>
|
|
<para>
|
|
Todos os parâmetros que não estão na lista acima são exibidos como
|
|
nome/valor dentro de <select>-tag. Eles são ignorados se o opcional
|
|
<emphasis>name</emphasis> não é fornecido.
|
|
</para>
|
|
<example>
|
|
<title>html_options</title>
|
|
<programlisting>
|
|
<![CDATA[
|
|
index.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','Carlie Brown'));
|
|
$smarty->assign('customer_id', 1001);
|
|
$smarty->display('index.tpl');
|
|
|
|
index.tpl:
|
|
|
|
<select name=customer_id>
|
|
{html_options values=$cust_ids selected=$customer_id output=$cust_names}
|
|
</select>
|
|
|
|
|
|
index.php:
|
|
|
|
require('Smarty.class.php');
|
|
$smarty = new Smarty;
|
|
$smarty->assign('cust_options', array(
|
|
1001 => 'Taniel Franklin',
|
|
1002 => 'Fernando Correa',
|
|
1003 => 'Marcelo Pereira',
|
|
1004 => 'Charlie Brown'));
|
|
$smarty->assign('customer_id', 1001);
|
|
$smarty->display('index.tpl');
|
|
|
|
index.tpl:
|
|
|
|
<select name=customer_id>
|
|
{html_options options=$cust_options selected=$customer_id}
|
|
</select>
|
|
|
|
|
|
OUTPUT: (both examples)
|
|
|
|
<select name=customer_id>
|
|
<option value="1000">Taniel Franklin</option>
|
|
<option value="1001" selected="selected">Fernando Correa</option>
|
|
<option value="1002">Marcelo Pereira</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
|
|
--> |