mirror of
https://github.com/smarty-php/smarty.git
synced 2025-11-05 23:01:37 +01:00
149 lines
5.3 KiB
XML
149 lines
5.3 KiB
XML
|
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
|||
|
|
<!-- $Revision$ -->
|
|||
|
|
<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>Exigido</entry>
|
|||
|
|
<entry>Padr<EFBFBD>o</entry>
|
|||
|
|
<entry>Descri<EFBFBD><EFBFBD>o</entry>
|
|||
|
|
</row>
|
|||
|
|
</thead>
|
|||
|
|
<tbody>
|
|||
|
|
<row>
|
|||
|
|
<entry>values</entry>
|
|||
|
|
<entry>array</entry>
|
|||
|
|
<entry>Sim, a menos que usando atributos de op<6F><70>es</entry>
|
|||
|
|
<entry><emphasis>n/a</emphasis></entry>
|
|||
|
|
<entry>um array de valores para o menu dropdown</entry>
|
|||
|
|
</row>
|
|||
|
|
<row>
|
|||
|
|
<entry>output</entry>
|
|||
|
|
<entry>array</entry>
|
|||
|
|
<entry>Sim, a menos que usando atributos de op<6F><70>es</entry>
|
|||
|
|
<entry><emphasis>n/a</emphasis></entry>
|
|||
|
|
<entry>um array de sa<73>da para o menu dropdown</entry>
|
|||
|
|
</row>
|
|||
|
|
<row>
|
|||
|
|
<entry>selected</entry>
|
|||
|
|
<entry>string/array</entry>
|
|||
|
|
<entry>N<EFBFBD>o</entry>
|
|||
|
|
<entry><emphasis>empty</emphasis></entry>
|
|||
|
|
<entry>o elemento do option selecionado</entry>
|
|||
|
|
</row>
|
|||
|
|
<row>
|
|||
|
|
<entry>options</entry>
|
|||
|
|
<entry>associative array</entry>
|
|||
|
|
<entry>Sim, a menos que usando valores e sa<73>da</entry>
|
|||
|
|
<entry><emphasis>n/a</emphasis></entry>
|
|||
|
|
<entry>um array associativo de valores e sa<73>da</entry>
|
|||
|
|
</row>
|
|||
|
|
<row>
|
|||
|
|
<entry>name</entry>
|
|||
|
|
<entry>string</entry>
|
|||
|
|
<entry>N<EFBFBD>o</entry>
|
|||
|
|
<entry><emphasis>empty</emphasis></entry>
|
|||
|
|
<entry>nome do grupo selecionado</entry>
|
|||
|
|
</row>
|
|||
|
|
</tbody>
|
|||
|
|
</tgroup>
|
|||
|
|
</informaltable>
|
|||
|
|
<para>
|
|||
|
|
html_options <20> uma fun<75><6E>o customizada que cria um grupo html option com os dados fornecidos.
|
|||
|
|
Ela est<73> atenta de quais itens s<>o selecionados por defini<6E><69>o. Atributos exigidos s<>o valores e
|
|||
|
|
sa<73>da, a menos que voc<6F> use options
|
|||
|
|
no lugar.
|
|||
|
|
</para>
|
|||
|
|
<para>
|
|||
|
|
Se um valor dado <20> um array, ele ser<65> tratado como um OPTGROUP html,
|
|||
|
|
e mostrar<61> os grupos.
|
|||
|
|
Recursion <20> suportado com OPTGROUP. Todas as sa<73>das est<73>o compat<61>veis com XHTML.
|
|||
|
|
</para>
|
|||
|
|
<para>
|
|||
|
|
Se o atributo opcional <emphasis>name</emphasis> <20> dado, as tags
|
|||
|
|
<select name="groupname"></select> ir<69>o enclausurar a lista de op<6F><70>es.
|
|||
|
|
Caso contr<74>rio apenas a lista de op<6F><70>es <20> gerada.
|
|||
|
|
</para>
|
|||
|
|
<para>
|
|||
|
|
Todos os par<61>metros que n<>o est<73>o na lista acima s<>o exibidos como
|
|||
|
|
name/value-pairs dentro de <select>-tag. Eles s<>o ignorados se o opcional
|
|||
|
|
<emphasis>name</emphasis>n<EFBFBD>o <20> dado.
|
|||
|
|
</para>
|
|||
|
|
<example>
|
|||
|
|
<title>html_options</title>
|
|||
|
|
<programlisting>
|
|||
|
|
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
|
|||
|
|
-->
|