{html_checkboxes}鏄竴涓�
鑷畾涔夊嚱鏁�锛岀敤浜庡垱寤篐TML鐨勫閫夋缁勫拰鎻愪緵鏁版嵁銆�
璇锋敞鎰忛粯璁ら�変腑鐨勬儏鍐点��
| 鍙傛暟鍚嶇О | 绫诲瀷 | 蹇呴�夊弬鏁� | 榛樿鍊� | 璇存槑 |
|---|---|---|---|---|
| name | string | No | checkbox | 澶氶�夋鐨勫悕绉� |
| values | array | 蹇呴�夛紝闄ら潪浣跨敤options灞炴�� | n/a | 澶氶�夋鐨勫�兼暟鎹� |
| output | array | 蹇呴�夛紝闄ら潪浣跨敤options灞炴�� | n/a | 澶氶�夋鐨勬樉绀烘暟鎹� |
| selected | string/array | No | empty | 閫変腑鐨勯」锛堜竴涓垨澶氫釜锛� |
| options | associative array | 蹇呴』, 闄ら潪浣跨敤values 鍜� output灞炴�� | n/a | 澶氶�夋鐨勫��-鏄剧ず鐨勬暟缁� |
| separator | string | No | empty | 瀛楃涓蹭腑鍒嗛殧姣忛」鐨勫瓧绗� |
| assign | string | No | empty | 灏嗗閫夋鏍囩璧嬪�煎埌鏁扮粍锛岃�屼笉鏄緭鍑� |
| labels | boolean | No | TRUE |
鍦ㄨ緭鍑轰腑澧炲姞<label>鏍囩 |
| label_ids | boolean | No | FALSE |
缁�<label> 鍜� <input>璁剧疆ID灞炴�� |
| escape | boolean | No | TRUE |
灏嗚緭鍑轰腑鐨�/杞崲(鍊兼�绘槸浼氳杞崲) |
蹇呴』璧嬪�肩殑灞炴�ф槸
values鍜�output, 闄ら潪浣跨敤options鏉ヤ唬鏇裤��鍏ㄩ儴鐨勮緭鍑烘爣绛鹃兘閬靛惊XHTML瑙勫垯銆�
浠讳綍涓嶅湪涓婇潰鍒楄〃涓殑閿�煎灞炴�э紝閮戒細琚緭鍑哄埌<input>鏍囩涓綔涓哄睘鎬у拰鍊笺��
Example聽8.6.聽{html_checkboxes}
<?php
$smarty->assign('cust_ids', array(1000,1001,1002,1003));
$smarty->assign('cust_names', array(
'Joe Schmoe',
'Jack Smith',
'Jane Johnson',
'Charlie Brown')
);
$smarty->assign('customer_id', 1001);
?>
妯℃澘鏄細
{html_checkboxes name='id' values=$cust_ids output=$cust_names
selected=$customer_id separator='<br />'}
鎴栬�匬HP浠g爜锛�
<?php
$smarty->assign('cust_checkboxes', array(
1000 => 'Joe Schmoe',
1001 => 'Jack Smith',
1002 => 'Jane Johnson',
1003 => 'Charlie Brown')
);
$smarty->assign('customer_id', 1001);
?>
妯℃澘鏄細
{html_checkboxes name='id' options=$cust_checkboxes
selected=$customer_id separator='<br />'}
涓婇潰涓や釜渚嬪瓙鐨勮緭鍑猴細
<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 />
Example聽8.7.聽 鏁版嵁搴撲緥瀛�(渚嬪 PEAR 鎴� ADODB):
<?php
$sql = 'select type_id, types from contact_types order by type';
$smarty->assign('contact_types',$db->getAssoc($sql));
$sql = 'select contact_id, contact_type_id, contact '
.'from contacts where contact_id=12';
$smarty->assign('contact',$db->getRow($sql));
?>
杈撳嚭锛�
{html_checkboxes name='contact_type_id' options=$contact_types
selected=$contact.contact_type_id separator='<br />'}
鍙傝
{html_radios}
鍜�
{html_options}
