Home >Backend Development >PHP Tutorial >How Smarty generates simple form elements

How Smarty generates simple form elements

*文
*文Original
2018-01-02 09:55:571421browse

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(&#39;cust_ids&#39;,array(1000,1001,1002,1003));
$smarty->assign(&#39;cust_names&#39;,array(&#39;丁庆&#39;,&#39;闫磊&#39;,&#39;吕东&#39;,&#39;宋子健&#39;));
$smarty->assign(&#39;customer_id&#39;,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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn