How Smarty generates simple form elements

*文
Release: 2023-03-18 21:04:01
Original
1375 people have browsed it

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");
?>
Copy after login

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 }>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!