The examples in this article describe a method for smarty simple generation of form elements. Share to everyone for your reference, specific as follows:
The principle of smarty generating form element functionality is to give Smarty an array for generating and displaying menus or options, and for passing the value of an option to match the default selection:
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 (' Dingqing ', ' Len Lei ', ' Lu Dong ', ' Song Zijian '));
$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>
PS: Here recommend a few of the site's format/landscaping/conversion tools to help you organize the messy code, I believe that we can use in future development:
PHP code online format Landscaping tools:
Http://tools.jb51.net/code/phpformat
JavaScript code Landscaping/compression/formatting/encryption Tools:
http://tools.jb51.net/code/jscompress
Online XML format/compression tools:
Http://tools.jb51.net/code/xmlformat
JSON Code Formatting Landscaping tool:
Http://tools.jb51.net/code/json
Online Xml/json Mutual Conversion tool:
Http://tools.jb51.net/code/xmljson
JSON code online Format/beautify/compress/edit/Convert tools:
Http://tools.jb51.net/code/jsoncodeformat
SQL code Online formatting Landscaping tools:
Http://tools.jb51.net/code/sqlcodeformat
More interested in smarty related content readers can view the site topics: "Smarty Template Primer Tutorial", "PHP Template Technology Summary", "PHP based on PDO Operation Database Skills summary", "PHP Operations and Operator Usage Summary", "PHP Network Programming Skills Summary", " Introduction to PHP Basic Grammar, "Introduction to PHP object-oriented programming", "PHP string (String) Usage Summary", "Php+mysql Database Operations Tutorial" and "PHP common database Operation Skills Summary"
I hope this article will help you with the PHP program design based on Smarty template.