mirror of
				https://github.com/smarty-php/smarty.git
				synced 2025-10-31 12:21:36 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			154 lines
		
	
	
		
			4.1 KiB
		
	
	
	
		
			XML
		
	
	
	
	
	
			
		
		
	
	
			154 lines
		
	
	
		
			4.1 KiB
		
	
	
	
		
			XML
		
	
	
	
	
	
| <?xml version="1.0" encoding="windows-1251"?>
 | |
| <!-- $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>Èìÿ àòòðèáóòà</entry>
 | |
|     <entry>Òèï</entry>
 | |
|     <entry>Îáÿçàòåëåí</entry>       
 | |
|     <entry>Ïî óìîë÷àíèþ</entry>
 | |
|     <entry>Îïèñàíèå</entry>
 | |
|    </row>
 | |
|   </thead>
 | |
|   <tbody>
 | |
|    <row>
 | |
|     <entry>values</entry>
 | |
|     <entry>ìàññèâ</entry>
 | |
|     <entry>Äà, åñëè íå óêàçàí àòòðèáóò options</entry>
 | |
|     <entry><emphasis>n/a</emphasis></entry>
 | |
|     <entry>ìàññèâ çíà÷åíèé äëÿ âûïàäàþùåãî ñïèñêà</entry>
 | |
|    </row>
 | |
|    <row>
 | |
|     <entry>output</entry>
 | |
|     <entry>ìàññèâ</entry>
 | |
|     <entry>Äà, åñëè íå óêàçàí àòòðèáóò options</entry>
 | |
|     <entry><emphasis>n/a</emphasis></entry>
 | |
|     <entry>ìàññèâ íàçâàíèé äëÿ âûïàäàþùåãî ñïèñêà</entry>
 | |
|    </row>
 | |
|    <row>
 | |
|     <entry>selected</entry>
 | |
|     <entry>string/array</entry>
 | |
|     <entry>Íåò</entry>
 | |
|     <entry><emphasis>ïóñòî</emphasis></entry>
 | |
|     <entry>Âûáðàííûé ýëåìåíò(û)</entry>
 | |
|    </row>
 | |
|    <row>
 | |
|     <entry>options</entry>
 | |
|     <entry>àññîöèàòèâíûé ìàññèâ</entry>
 | |
|     <entry>Äà, åñëè íå óêàçàíû àòòðèáóòû values è output</entry>
 | |
|     <entry><emphasis>n/a</emphasis></entry>
 | |
|     <entry>àññîöèàòèâíûé ìàññèâ çíà÷åíèé è íàçâàíèé</entry>
 | |
|    </row>
 | |
|    <row>
 | |
|     <entry>name</entry>
 | |
|     <entry>ñòðîêà (string)</entry>
 | |
|     <entry>Íåò</entry>
 | |
|     <entry><emphasis>ïóñòî</emphasis></entry>
 | |
|     <entry>Íàçâàíèå âûïàäàþùåãî ñïèñêà</entry>
 | |
|    </row>
 | |
|   </tbody>
 | |
|   </tgroup>
 | |
|  </informaltable>
 | |
|  <para>
 | |
|   ïîëüçîâàòåëüñêàÿ ôóíêöèÿ html_options ãåíåðèðóåò ãðóïïó html òýãîâ
 | |
|   option ïî óêàçàííîé èíôîðìàöèè. Òàêæå çàáîòèòñÿ î âûáðàííûõ ïî
 | |
|   óìîë÷àíèþ ýëåìåíòàõ. Àòòðèáóòû values è output îáÿçàòåëüíû, åñëè íå 
 | |
|   óêàçàí àòòðèáóò options.
 | |
|  </para>
 | |
|  <para>
 | |
|   Åñëè äàííîå çíà÷åíèå - ìàññèâ, òî îíî áóäåò ïðåäñòàâëåíî â âèäå
 | |
|   html OPTGROUP. Ðåêóðñèÿ ñ OPTGROUP ïîääåðæèâàåòñÿ. Âåñü âûâîä
 | |
|   ñîâìåñòèì ñ XHTML.
 | |
|  </para>
 | |
|  <para>
 | |
|   Åñëè óêàçàí íåîáÿçàòåëüíûé àòòðèáóò <emphasis>name</emphasis>,
 | |
|   òî ãðóïïà îïöèé çàêëþ÷èòñÿ â òýã <select 
 | |
|   name="groupname"> è </select>, èíà÷å ñãåíåðèðóåòñÿ òîëüêî 
 | |
|   ãðóïïà îïöèé.
 | |
|  </para>
 | |
|  <para>
 | |
|   Âñå ïàðàìåòðû, êîòîðûå íå óêàçàíû âûøå, âûâîäÿòñÿ â âèäå
 | |
|   ïàðû name/value âíóòðè òýãà <select>-tag. Îíè èãíîðèðóþòñÿ,
 | |
|   åñëè àòòðèáóò <emphasis>name</emphasis> íå óêàçàí.
 | |
|  </para>
 | |
|  <example>
 | |
|   <title>html_options</title>
 | |
|   <programlisting>
 | |
| <![CDATA[
 | |
|  index.php:
 | |
| 
 | |
|  require('Smarty.php.class');
 | |
|  $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.php.class');
 | |
|  $smarty = new Smarty;
 | |
|  $smarty->assign('cust_options', array(
 | |
|     1001 => 'Joe Schmoe',
 | |
|     1002 => 'Jack Smith',
 | |
|     1003 => 'Jane Johnson',
 | |
|     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">Joe Schmoe</option>
 | |
|   <option value="1001" selected="selected">Jack Smith</option>
 | |
|   <option value="1002">Jane Johnson</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
 | |
| -->
 |