Example of how Smarty simply generates form elements, smarty form_PHP tutorial

WBOY
Release: 2016-07-12 08:50:44
Original
943 people have browsed it

An example of Smarty's simple method of generating form elements, smarty form

This article describes an example of Smarty's simple method of generating form elements. Share it with everyone for your reference, the details are as follows:

The principle of smarty generating form elements is to give smarty an array to generate and display menus or options, and in addition, pass the value of an option for matching the default selection:

An example is as follows:

php file: index.php

<&#63;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");
&#63;>

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

PS: Here are several formatting/beautifying/conversion tools recommended on this site to help you sort out the messy code. I believe everyone can use it in future development:

php code online formatting and beautification tool:
http://tools.jb51.net/code/phpformat

JavaScript code beautification/compression/formatting/encryption tool:
http://tools.jb51.net/code/jscompress

Online XML formatting/compression tool:
http://tools.jb51.net/code/xmlformat

JSON code formatting and beautification tool:
http://tools.jb51.net/code/json

Online XML/JSON conversion tool:
http://tools.jb51.net/code/xmljson

JSON code online formatting/beautifying/compressing/editing/conversion tool:
http://tools.jb51.net/code/jsoncodeformat

SQL code online formatting and beautification tool:
http://tools.jb51.net/code/sqlcodeformat

Readers who are interested in more Smarty-related content can check out the special topics on this site: "Basic Tutorial for Getting Started with Smarty Templates", "Summary of PHP Template Technology", "Summary of PHP Database Operation Skills Based on PDO", "PHP Operations and Operators" Usage summary", "PHP network programming skills summary", "PHP basic syntax introductory tutorial", "php object-oriented programming introductory tutorial", "php string (string) usage summary", "php mysql database operation introductory tutorial" and "Summary of Common Database Operation Skills in PHP"

I hope this article will be helpful to everyone’s PHP program design based on smarty templates.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1133101.htmlTechArticleSmarty’s simple method of generating form elements, smarty form. This article describes an example of Smarty’s simple method of generating form elements. Share it with everyone for your reference, the details are as follows: smarty student...
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!