This article mainly introduces the method of Smarty to simply generate form elements, and involves the related skills of Smarty template file operation. Friends in need can refer to it. I hope to be helpful.
The details are as follows:
The principle of smarty generating form element function is: give smarty an array to generate and display menus or options, and pass the value of an option for default Selected matches:
Examples are as follows:
php file: index.php
<?php include("smarty_inc.php"); $smarty->assign('cust_ids',array(1000,1001,1002,1003)); $smarty->assign('cust_names',array('丁庆','闫磊','吕东','宋子健')); $smarty->assign('customer_id',1003); $smarty->display("index.html"); ?>
Template file: index.html
<select name=customer_id onkeypress=""> <{html_options values=$cust_ids selected=$customer_id output=$cust_names}> </select> <hr /> <{html_radios name="id" values=$cust_ids selected=$customer_id output=$cust_names }>
Related recommendations :
Smarty template engine video teaching material course recommendation
How about php built-in functions Sharing examples of calling in smarty
php What are the smarty template operators? How to use operators?
The above is the detailed content of How Smarty generates simple form elements. For more information, please follow other related articles on the PHP Chinese website!