blob: 93ef4e578e325dd99a13bffb0b44275ce460357a [file] [log] [blame]
Andrey Andreevc5769952019-01-16 17:49:35 +02001
2
3<!DOCTYPE html>
4<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
5<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
6<head>
7 <meta charset="utf-8">
8 <meta name="viewport" content="width=device-width, initial-scale=1.0">
9
10 <title>Form Helper &mdash; CodeIgniter 3.1.10 documentation</title>
11
12
13
14
15 <link rel="shortcut icon" href="../_static/ci-icon.ico"/>
16
17
18
19 <link href='https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic|Roboto+Slab:400,700|Inconsolata:400,700&subset=latin,cyrillic' rel='stylesheet' type='text/css'>
20
21
22
23
24
25
26
27
28
29 <link rel="stylesheet" href="../_static/css/citheme.css" type="text/css" />
30
31
32
33 <link rel="index" title="Index"
34 href="../genindex.html"/>
35 <link rel="search" title="Search" href="../search.html"/>
36 <link rel="top" title="CodeIgniter 3.1.10 documentation" href="../index.html"/>
37 <link rel="up" title="Helpers" href="index.html"/>
38 <link rel="next" title="HTML Helper" href="html_helper.html"/>
39 <link rel="prev" title="File Helper" href="file_helper.html"/>
40
41
42 <script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script>
43
44</head>
45
46<body class="wy-body-for-nav" role="document">
47
48 <div id="nav">
49 <div id="nav_inner">
50
51
52
53 <div id="pulldown-menu" class="ciNav">
54 <ul>
55<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li>
56</ul>
57<ul>
58<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul>
59<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li>
60<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li>
61<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li>
62<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li>
63</ul>
64</li>
65</ul>
66<ul>
67<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul>
68<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li>
69<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li>
70<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li>
71<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li>
72<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li>
73<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li>
74</ul>
75</li>
76</ul>
77<ul>
78<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul>
79<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li>
80<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li>
81<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li>
82<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li>
83</ul>
84</li>
85</ul>
86<ul>
87<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul>
88<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li>
89<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li>
90</ul>
91</li>
92</ul>
93<ul>
94<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul>
95<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li>
96<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li>
97<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li>
98<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li>
99<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li>
100<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li>
101<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li>
102<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li>
103<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li>
104<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li>
105<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li>
106<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li>
107<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li>
108<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li>
109<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li>
110<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li>
111<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li>
112<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li>
113<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li>
114<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li>
115<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li>
116<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li>
117<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li>
118<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li>
119<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li>
120<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li>
121</ul>
122</li>
123</ul>
124<ul>
125<li class="toctree-l1"><a class="reference internal" href="../libraries/index.html">Libraries</a><ul>
126<li class="toctree-l2"><a class="reference internal" href="../libraries/benchmark.html">Benchmarking Class</a></li>
127<li class="toctree-l2"><a class="reference internal" href="../libraries/caching.html">Caching Driver</a></li>
128<li class="toctree-l2"><a class="reference internal" href="../libraries/calendar.html">Calendaring Class</a></li>
129<li class="toctree-l2"><a class="reference internal" href="../libraries/cart.html">Shopping Cart Class</a></li>
130<li class="toctree-l2"><a class="reference internal" href="../libraries/config.html">Config Class</a></li>
131<li class="toctree-l2"><a class="reference internal" href="../libraries/email.html">Email Class</a></li>
132<li class="toctree-l2"><a class="reference internal" href="../libraries/encrypt.html">Encrypt Class</a></li>
133<li class="toctree-l2"><a class="reference internal" href="../libraries/encryption.html">Encryption Library</a></li>
134<li class="toctree-l2"><a class="reference internal" href="../libraries/file_uploading.html">File Uploading Class</a></li>
135<li class="toctree-l2"><a class="reference internal" href="../libraries/form_validation.html">Form Validation</a></li>
136<li class="toctree-l2"><a class="reference internal" href="../libraries/ftp.html">FTP Class</a></li>
137<li class="toctree-l2"><a class="reference internal" href="../libraries/image_lib.html">Image Manipulation Class</a></li>
138<li class="toctree-l2"><a class="reference internal" href="../libraries/input.html">Input Class</a></li>
139<li class="toctree-l2"><a class="reference internal" href="../libraries/javascript.html">Javascript Class</a></li>
140<li class="toctree-l2"><a class="reference internal" href="../libraries/language.html">Language Class</a></li>
141<li class="toctree-l2"><a class="reference internal" href="../libraries/loader.html">Loader Class</a></li>
142<li class="toctree-l2"><a class="reference internal" href="../libraries/migration.html">Migrations Class</a></li>
143<li class="toctree-l2"><a class="reference internal" href="../libraries/output.html">Output Class</a></li>
144<li class="toctree-l2"><a class="reference internal" href="../libraries/pagination.html">Pagination Class</a></li>
145<li class="toctree-l2"><a class="reference internal" href="../libraries/parser.html">Template Parser Class</a></li>
146<li class="toctree-l2"><a class="reference internal" href="../libraries/security.html">Security Class</a></li>
147<li class="toctree-l2"><a class="reference internal" href="../libraries/sessions.html">Session Library</a></li>
148<li class="toctree-l2"><a class="reference internal" href="../libraries/table.html">HTML Table Class</a></li>
149<li class="toctree-l2"><a class="reference internal" href="../libraries/trackback.html">Trackback Class</a></li>
150<li class="toctree-l2"><a class="reference internal" href="../libraries/typography.html">Typography Class</a></li>
151<li class="toctree-l2"><a class="reference internal" href="../libraries/unit_testing.html">Unit Testing Class</a></li>
152<li class="toctree-l2"><a class="reference internal" href="../libraries/uri.html">URI Class</a></li>
153<li class="toctree-l2"><a class="reference internal" href="../libraries/user_agent.html">User Agent Class</a></li>
154<li class="toctree-l2"><a class="reference internal" href="../libraries/xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li>
155<li class="toctree-l2"><a class="reference internal" href="../libraries/zip.html">Zip Encoding Class</a></li>
156</ul>
157</li>
158</ul>
159<ul>
160<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul>
161<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li>
162<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li>
163<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li>
164<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li>
165<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li>
166<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li>
167<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li>
168<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li>
169<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li>
170<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li>
171<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li>
172<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li>
173<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li>
174<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li>
175</ul>
176</li>
177</ul>
178<ul class="current">
179<li class="toctree-l1 current"><a class="reference internal" href="index.html">Helpers</a><ul class="current">
180<li class="toctree-l2"><a class="reference internal" href="array_helper.html">Array Helper</a></li>
181<li class="toctree-l2"><a class="reference internal" href="captcha_helper.html">CAPTCHA Helper</a></li>
182<li class="toctree-l2"><a class="reference internal" href="cookie_helper.html">Cookie Helper</a></li>
183<li class="toctree-l2"><a class="reference internal" href="date_helper.html">Date Helper</a></li>
184<li class="toctree-l2"><a class="reference internal" href="directory_helper.html">Directory Helper</a></li>
185<li class="toctree-l2"><a class="reference internal" href="download_helper.html">Download Helper</a></li>
186<li class="toctree-l2"><a class="reference internal" href="email_helper.html">Email Helper</a></li>
187<li class="toctree-l2"><a class="reference internal" href="file_helper.html">File Helper</a></li>
188<li class="toctree-l2 current"><a class="current reference internal" href="#">Form Helper</a></li>
189<li class="toctree-l2"><a class="reference internal" href="html_helper.html">HTML Helper</a></li>
190<li class="toctree-l2"><a class="reference internal" href="inflector_helper.html">Inflector Helper</a></li>
191<li class="toctree-l2"><a class="reference internal" href="language_helper.html">Language Helper</a></li>
192<li class="toctree-l2"><a class="reference internal" href="number_helper.html">Number Helper</a></li>
193<li class="toctree-l2"><a class="reference internal" href="path_helper.html">Path Helper</a></li>
194<li class="toctree-l2"><a class="reference internal" href="security_helper.html">Security Helper</a></li>
195<li class="toctree-l2"><a class="reference internal" href="smiley_helper.html">Smiley Helper</a></li>
196<li class="toctree-l2"><a class="reference internal" href="string_helper.html">String Helper</a></li>
197<li class="toctree-l2"><a class="reference internal" href="text_helper.html">Text Helper</a></li>
198<li class="toctree-l2"><a class="reference internal" href="typography_helper.html">Typography Helper</a></li>
199<li class="toctree-l2"><a class="reference internal" href="url_helper.html">URL Helper</a></li>
200<li class="toctree-l2"><a class="reference internal" href="xml_helper.html">XML Helper</a></li>
201</ul>
202</li>
203</ul>
204
205 </div>
206
207
208 </div>
209</div>
210<div id="nav2">
211 <a href="#" id="openToc">
212 <img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kAAQAEAAAARgAA/+4ADkFkb2JlAGTAAAAAAf/bAIQABAMDAwMDBAMDBAYEAwQGBwUEBAUHCAYGBwYGCAoICQkJCQgKCgwMDAwMCgwMDQ0MDBERERERFBQUFBQUFBQUFAEEBQUIBwgPCgoPFA4ODhQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQU/8AAEQgAKwCaAwERAAIRAQMRAf/EAHsAAQAABwEBAAAAAAAAAAAAAAABAwQFBgcIAgkBAQAAAAAAAAAAAAAAAAAAAAAQAAEDAwICBwYEAgsAAAAAAAIBAwQAEQUSBiEHkROTVNQWGDFBUVIUCHEiMtOUFWGBobHRQlMkZIRVEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwDSC+ygkOOaUoKigUCgUCgUCgUCgUCgUCgUCgkuGguIP9FBMFb0Hqg7We+3jlmIqqYFf4ub+/QYlnOR/LqIBKGFUbf8qWv971BytQXXE7Y3Lnm3HsFhp2TaZJAdchRXpIgSpdEJWxJEW3xoKV7F5OMy7JkQn2o7D6w33XGjEAkoiqrJEqIiOIiKuhePCgqp22dyYyS3CyWHnQ5joG61HkRnmnTbaFSMhExRVQRRVJU9iUHjE7ez+fJ0MFipmUNhBV8YUd2SoIV9KkjQla9ltegttBdPLW4/qocL+UTfrMiHW4+P9M71shuyrqaHTcxsl7jegpsji8nh5ZwMvDfgTm0RTjSmjYdFCS6KoOIipdFunCgmNYTMv457MMY6U7iI6oMieDDhRm1VbIhuoOkbqtuK0Hpzb+eZcYZexUxt6UyUqK2cd0SdjtgrhOgijcgERUlJOCIl6CpgbP3blRI8XgMjNARAyKNDfeRBdFDBVUAXgQrqH4pxoJTu2NysY97LP4ac1io5q1InHFeGO24LnVKJuKOkSQ/yKir+rh7aCLG1dzypZQI2FnvTgccYOM3FeN0XWERXAUEFVQgQkUktdLpegm+Td3/Xli/L+S/mYNJIOF9G/wBeLKrZHFb0akG6W1WtQWSg3Dyg5e7V3fipE3O4/wCrktyzYA+ufas2LbZIlmnAT2kvuoN1wft95augilglX/tzP3qCu9O3LL/wV/i5v79BvmTADq14UGu91467Z6U9y0HzH/ncj/U/sT/CgynZG7I2NezpZGUjIycJkYkZSG+uQ81pbBNKLxJfjwoMqZ3/ALYHl35AJ7/cuwHcu5k7r1Q5pHetBjquqVVJWGxj9Zrtcl/Ggy3dHMvauR3HFZj5nHNxSyW5JISYDMoIwx8tFIGHZhPNaykGapr6rUAiicEoMG21lMRj8buPAz8xhJrr7uOeiPTCyAwXUaGR1mgozbTusOsFLEiJ7fbQa/h7gcjy2H3V6xppwDNtUSxCJIqp7valBuWVzJ22xuCROXNNZiJkMtms0DbjUkAZjzoDrTMd9dDRI44ZC2YsrYdKWP2WDT2S3N9dNdlRYrGMYc06IURXSYb0igrpWS485xVNS6nF4rwslkoMwnbpgZLB7bmt5uMweAhDEl4B5uSLzzqTnnyVpW2jaJHRMSIjdDiiotvy3DOE5rYTEbkl5yFn28k7JyG4c7AU2HtLH1uKfaiMPI40CdYbpNtmLdwTSn5rewLNld+7TLdeal4WarWBkbVKBjgdElMJJwAAY5fl4kB3b1fp4XvagsGS3FjJfLzDNtS8aeXx7LzT7TyzByQE5PccRGRC0ZRUDRV6y62vbjagzLmJzS2vuPK43JY6aP1TW6Jz+RIWyFtyC06y3EkiiinAo7YCqfq1AqqnGgsOH3lhZO8d1pmcpB8j5XIm9OYlBJSQ/FSS4427DKO0RC8AlcEMhFdViRR1WDWR5t3WXVuL1d106kG9vdeye2g60+1FDyW0shIcXVpyroXt8I8dfd+NB1vioAdWnD3UF1+gD4UFc6CEKpagxXN43rwJLUHz7yX2c8zokt9uHlsPIhA4aRnnHJTLptIS6CNsY7iASpxUUMkReGpfbQW0vtN5pitvrsN28rwtBD0nc0+/Yft5XhaB6TuaXfsP28rwtA9J3NPv2H7eV4Wgek7mn37D9vK8LQPSdzT79h+3leFoHpO5pd+w/byvC0D0nc0u/Yft5XhaB6TuaXfsP28rwtA9J3NLv2H7eV4Wgek7ml37D9vK8LQPSdzS79h+3leFoHpO5p9+w/byvC0E9r7Reazy2HIYVPxkS/CUHVn26cosxyv2g7h89LYmZSXOenvLEQ1YaQ222RATcQCP8rSGqqA8S02W2pQ6FhMoAIlqCtsnwoCpdKClejI4i3Sgtb+GBxVuNBSFt1pV/RQefLjPyUDy4z8lA8uM/JQPLjPyUDy4z8lA8uM/JQPLjPyUDy4z8lA8uM/JQPLjPyUDy4z8lA8utJ/koJ7WCbBU/LQXOPAFq1koK8B0pag90CggtBBf6qB0UDooHRQOigdFA6KB0UDooHRQOigdFA6KB0UDooI0EaBQf//Z" title="Toggle Table of Contents" alt="Toggle Table of Contents" />
213 </a>
214</div>
215
216 <div class="wy-grid-for-nav">
217
218
219 <nav data-toggle="wy-nav-shift" class="wy-nav-side">
220 <div class="wy-side-nav-search">
221
222 <a href="../index.html" class="fa fa-home"> CodeIgniter</a>
223
224
225<div role="search">
226 <form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
227 <input type="text" name="q" placeholder="Search docs" />
228 <input type="hidden" name="check_keywords" value="yes" />
229 <input type="hidden" name="area" value="default" />
230 </form>
231</div>
232 </div>
233
234 <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
235
236
237
238 <ul>
239<li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li>
240</ul>
241<ul>
242<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul>
243<li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li>
244<li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li>
245<li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li>
246<li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li>
247</ul>
248</li>
249</ul>
250<ul>
251<li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul>
252<li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li>
253<li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li>
254<li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li>
255<li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li>
256<li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li>
257<li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li>
258</ul>
259</li>
260</ul>
261<ul>
262<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul>
263<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li>
264<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li>
265<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li>
266<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li>
267</ul>
268</li>
269</ul>
270<ul>
271<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul>
272<li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li>
273<li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li>
274</ul>
275</li>
276</ul>
277<ul>
278<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul>
279<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li>
280<li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li>
281<li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li>
282<li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li>
283<li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li>
284<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li>
285<li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li>
286<li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li>
287<li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li>
288<li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li>
289<li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li>
290<li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li>
291<li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li>
292<li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li>
293<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li>
294<li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li>
295<li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li>
296<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li>
297<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li>
298<li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li>
299<li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li>
300<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li>
301<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li>
302<li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li>
303<li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li>
304<li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li>
305</ul>
306</li>
307</ul>
308<ul>
309<li class="toctree-l1"><a class="reference internal" href="../libraries/index.html">Libraries</a><ul>
310<li class="toctree-l2"><a class="reference internal" href="../libraries/benchmark.html">Benchmarking Class</a></li>
311<li class="toctree-l2"><a class="reference internal" href="../libraries/caching.html">Caching Driver</a></li>
312<li class="toctree-l2"><a class="reference internal" href="../libraries/calendar.html">Calendaring Class</a></li>
313<li class="toctree-l2"><a class="reference internal" href="../libraries/cart.html">Shopping Cart Class</a></li>
314<li class="toctree-l2"><a class="reference internal" href="../libraries/config.html">Config Class</a></li>
315<li class="toctree-l2"><a class="reference internal" href="../libraries/email.html">Email Class</a></li>
316<li class="toctree-l2"><a class="reference internal" href="../libraries/encrypt.html">Encrypt Class</a></li>
317<li class="toctree-l2"><a class="reference internal" href="../libraries/encryption.html">Encryption Library</a></li>
318<li class="toctree-l2"><a class="reference internal" href="../libraries/file_uploading.html">File Uploading Class</a></li>
319<li class="toctree-l2"><a class="reference internal" href="../libraries/form_validation.html">Form Validation</a></li>
320<li class="toctree-l2"><a class="reference internal" href="../libraries/ftp.html">FTP Class</a></li>
321<li class="toctree-l2"><a class="reference internal" href="../libraries/image_lib.html">Image Manipulation Class</a></li>
322<li class="toctree-l2"><a class="reference internal" href="../libraries/input.html">Input Class</a></li>
323<li class="toctree-l2"><a class="reference internal" href="../libraries/javascript.html">Javascript Class</a></li>
324<li class="toctree-l2"><a class="reference internal" href="../libraries/language.html">Language Class</a></li>
325<li class="toctree-l2"><a class="reference internal" href="../libraries/loader.html">Loader Class</a></li>
326<li class="toctree-l2"><a class="reference internal" href="../libraries/migration.html">Migrations Class</a></li>
327<li class="toctree-l2"><a class="reference internal" href="../libraries/output.html">Output Class</a></li>
328<li class="toctree-l2"><a class="reference internal" href="../libraries/pagination.html">Pagination Class</a></li>
329<li class="toctree-l2"><a class="reference internal" href="../libraries/parser.html">Template Parser Class</a></li>
330<li class="toctree-l2"><a class="reference internal" href="../libraries/security.html">Security Class</a></li>
331<li class="toctree-l2"><a class="reference internal" href="../libraries/sessions.html">Session Library</a></li>
332<li class="toctree-l2"><a class="reference internal" href="../libraries/table.html">HTML Table Class</a></li>
333<li class="toctree-l2"><a class="reference internal" href="../libraries/trackback.html">Trackback Class</a></li>
334<li class="toctree-l2"><a class="reference internal" href="../libraries/typography.html">Typography Class</a></li>
335<li class="toctree-l2"><a class="reference internal" href="../libraries/unit_testing.html">Unit Testing Class</a></li>
336<li class="toctree-l2"><a class="reference internal" href="../libraries/uri.html">URI Class</a></li>
337<li class="toctree-l2"><a class="reference internal" href="../libraries/user_agent.html">User Agent Class</a></li>
338<li class="toctree-l2"><a class="reference internal" href="../libraries/xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li>
339<li class="toctree-l2"><a class="reference internal" href="../libraries/zip.html">Zip Encoding Class</a></li>
340</ul>
341</li>
342</ul>
343<ul>
344<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul>
345<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li>
346<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li>
347<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li>
348<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li>
349<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li>
350<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li>
351<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li>
352<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li>
353<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li>
354<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li>
355<li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li>
356<li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li>
357<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li>
358<li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li>
359</ul>
360</li>
361</ul>
362<ul class="current">
363<li class="toctree-l1 current"><a class="reference internal" href="index.html">Helpers</a><ul class="current">
364<li class="toctree-l2"><a class="reference internal" href="array_helper.html">Array Helper</a></li>
365<li class="toctree-l2"><a class="reference internal" href="captcha_helper.html">CAPTCHA Helper</a></li>
366<li class="toctree-l2"><a class="reference internal" href="cookie_helper.html">Cookie Helper</a></li>
367<li class="toctree-l2"><a class="reference internal" href="date_helper.html">Date Helper</a></li>
368<li class="toctree-l2"><a class="reference internal" href="directory_helper.html">Directory Helper</a></li>
369<li class="toctree-l2"><a class="reference internal" href="download_helper.html">Download Helper</a></li>
370<li class="toctree-l2"><a class="reference internal" href="email_helper.html">Email Helper</a></li>
371<li class="toctree-l2"><a class="reference internal" href="file_helper.html">File Helper</a></li>
372<li class="toctree-l2 current"><a class="current reference internal" href="#">Form Helper</a></li>
373<li class="toctree-l2"><a class="reference internal" href="html_helper.html">HTML Helper</a></li>
374<li class="toctree-l2"><a class="reference internal" href="inflector_helper.html">Inflector Helper</a></li>
375<li class="toctree-l2"><a class="reference internal" href="language_helper.html">Language Helper</a></li>
376<li class="toctree-l2"><a class="reference internal" href="number_helper.html">Number Helper</a></li>
377<li class="toctree-l2"><a class="reference internal" href="path_helper.html">Path Helper</a></li>
378<li class="toctree-l2"><a class="reference internal" href="security_helper.html">Security Helper</a></li>
379<li class="toctree-l2"><a class="reference internal" href="smiley_helper.html">Smiley Helper</a></li>
380<li class="toctree-l2"><a class="reference internal" href="string_helper.html">String Helper</a></li>
381<li class="toctree-l2"><a class="reference internal" href="text_helper.html">Text Helper</a></li>
382<li class="toctree-l2"><a class="reference internal" href="typography_helper.html">Typography Helper</a></li>
383<li class="toctree-l2"><a class="reference internal" href="url_helper.html">URL Helper</a></li>
384<li class="toctree-l2"><a class="reference internal" href="xml_helper.html">XML Helper</a></li>
385</ul>
386</li>
387</ul>
388
389
390
391 </div>
392 &nbsp;
393 </nav>
394
395 <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
396
397
398 <nav class="wy-nav-top" role="navigation" aria-label="top navigation">
399 <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
400 <a href="../index.html">CodeIgniter</a>
401 </nav>
402
403
404
405 <div class="wy-nav-content">
406 <div class="rst-content">
407 <div role="navigation" aria-label="breadcrumbs navigation">
408 <ul class="wy-breadcrumbs">
409 <li><a href="../index.html">Docs</a> &raquo;</li>
410
411 <li><a href="index.html">Helpers</a> &raquo;</li>
412
413 <li>Form Helper</li>
414 <li class="wy-breadcrumbs-aside">
415
416 </li>
417 <div style="float:right;margin-left:5px;" id="closeMe">
418 <img title="Classic Layout" alt="classic layout" src="data:image/gif;base64,R0lGODlhFAAUAJEAAAAAADMzM////wAAACH5BAUUAAIALAAAAAAUABQAAAImlI+py+0PU5gRBRDM3DxbWoXis42X13USOLauUIqnlsaH/eY6UwAAOw==" />
419 </div>
420 </ul>
421 <hr/>
422</div>
423 <div role="main" class="document">
424
425 <div class="section" id="form-helper">
426<h1>Form Helper<a class="headerlink" href="#form-helper" title="Permalink to this headline"></a></h1>
427<p>The Form Helper file contains functions that assist in working with
428forms.</p>
429<div class="contents local topic" id="contents">
430<ul class="simple">
431<li><a class="reference internal" href="#loading-this-helper" id="id1">Loading this Helper</a></li>
432<li><a class="reference internal" href="#escaping-field-values" id="id2">Escaping field values</a></li>
433<li><a class="reference internal" href="#available-functions" id="id3">Available Functions</a></li>
434</ul>
435</div>
436<div class="custom-index container"></div><div class="section" id="loading-this-helper">
437<h2><a class="toc-backref" href="#id1">Loading this Helper</a><a class="headerlink" href="#loading-this-helper" title="Permalink to this headline"></a></h2>
438<p>This helper is loaded using the following code:</p>
439<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">load</span><span class="o">-&gt;</span><span class="na">helper</span><span class="p">(</span><span class="s1">&#39;form&#39;</span><span class="p">);</span>
440</pre></div>
441</div>
442</div>
443<div class="section" id="escaping-field-values">
444<h2><a class="toc-backref" href="#id2">Escaping field values</a><a class="headerlink" href="#escaping-field-values" title="Permalink to this headline"></a></h2>
445<p>You may need to use HTML and characters such as quotes within your form
446elements. In order to do that safely, you’ll need to use
447<a class="reference internal" href="../general/common_functions.html"><span class="doc">common function</span></a>
448<code class="xref py py-func docutils literal"><span class="pre">html_escape()</span></code>.</p>
449<p>Consider the following example:</p>
450<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$string</span> <span class="o">=</span> <span class="s1">&#39;Here is a string containing &quot;quoted&quot; text.&#39;</span><span class="p">;</span>
451
452<span class="o">&lt;</span><span class="nx">input</span> <span class="nx">type</span><span class="o">=</span><span class="s2">&quot;text&quot;</span> <span class="nx">name</span><span class="o">=</span><span class="s2">&quot;myfield&quot;</span> <span class="nx">value</span><span class="o">=</span><span class="s2">&quot;&lt;?php echo </span><span class="si">$string</span><span class="s2">; ?&gt;&quot;</span> <span class="o">/&gt;</span>
453</pre></div>
454</div>
455<p>Since the above string contains a set of quotes, it will cause the form
456to break. The <a class="reference internal" href="../general/common_functions.html#html_escape" title="html_escape"><code class="xref php php-func docutils literal"><span class="pre">html_escape()</span></code></a> function converts HTML special
457characters so that it can be used safely:</p>
458<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="o">&lt;</span><span class="nx">input</span> <span class="nx">type</span><span class="o">=</span><span class="s2">&quot;text&quot;</span> <span class="nx">name</span><span class="o">=</span><span class="s2">&quot;myfield&quot;</span> <span class="nx">value</span><span class="o">=</span><span class="s2">&quot;&lt;?php echo html_escape(</span><span class="si">$string</span><span class="s2">); ?&gt;&quot;</span> <span class="o">/&gt;</span>
459</pre></div>
460</div>
461<div class="admonition note">
462<p class="first admonition-title">Note</p>
463<p class="last">If you use any of the form helper functions listed on this page,
464the form values will be automatically escaped, so there is no need
465to call this function. Use it only if you are creating your own
466form elements.</p>
467</div>
468</div>
469<div class="section" id="available-functions">
470<h2><a class="toc-backref" href="#id3">Available Functions</a><a class="headerlink" href="#available-functions" title="Permalink to this headline"></a></h2>
471<p>The following functions are available:</p>
472<dl class="function">
473<dt id="form_open">
474<code class="descname">form_open</code><span class="sig-paren">(</span><span class="optional">[</span><em>$action = ''</em><span class="optional">[</span>, <em>$attributes = ''</em><span class="optional">[</span>, <em>$hidden = array()</em><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#form_open" title="Permalink to this definition"></a></dt>
475<dd><table class="docutils field-list" frame="void" rules="none">
476<col class="field-name" />
477<col class="field-body" />
478<tbody valign="top">
479<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
480<li><strong>$action</strong> (<em>string</em>) – Form action/target URI string</li>
481<li><strong>$attributes</strong> (<em>array</em>) – HTML attributes</li>
482<li><strong>$hidden</strong> (<em>array</em>) – An array of hidden fields’ definitions</li>
483</ul>
484</td>
485</tr>
486<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">An HTML form opening tag</p>
487</td>
488</tr>
489<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p>
490</td>
491</tr>
492</tbody>
493</table>
494<p>Creates an opening form tag with a base URL <strong>built from your config preferences</strong>.
495It will optionally let you add form attributes and hidden input fields, and
496will always add the <cite>accept-charset</cite> attribute based on the charset value in your
497config file.</p>
498<p>The main benefit of using this tag rather than hard coding your own HTML is that
499it permits your site to be more portable in the event your URLs ever change.</p>
500<p>Here’s a simple example:</p>
501<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">echo</span> <span class="nx">form_open</span><span class="p">(</span><span class="s1">&#39;email/send&#39;</span><span class="p">);</span>
502</pre></div>
503</div>
504<p>The above example would create a form that points to your base URL plus the
505“email/send” URI segments, like this:</p>
506<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="o">&lt;</span><span class="nx">form</span> <span class="nx">method</span><span class="o">=</span><span class="s2">&quot;post&quot;</span> <span class="nx">accept</span><span class="o">-</span><span class="nx">charset</span><span class="o">=</span><span class="s2">&quot;utf-8&quot;</span> <span class="nx">action</span><span class="o">=</span><span class="s2">&quot;http://example.com/index.php/email/send&quot;</span><span class="o">&gt;</span>
507</pre></div>
508</div>
509<p><strong>Adding Attributes</strong></p>
510<blockquote>
511<div><p>Attributes can be added by passing an associative array to the second
512parameter, like this:</p>
513<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$attributes</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span><span class="s1">&#39;class&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;email&#39;</span><span class="p">,</span> <span class="s1">&#39;id&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;myform&#39;</span><span class="p">);</span>
514<span class="k">echo</span> <span class="nx">form_open</span><span class="p">(</span><span class="s1">&#39;email/send&#39;</span><span class="p">,</span> <span class="nv">$attributes</span><span class="p">);</span>
515</pre></div>
516</div>
517<p>Alternatively, you can specify the second parameter as a string:</p>
518<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">echo</span> <span class="nx">form_open</span><span class="p">(</span><span class="s1">&#39;email/send&#39;</span><span class="p">,</span> <span class="s1">&#39;class=&quot;email&quot; id=&quot;myform&quot;&#39;</span><span class="p">);</span>
519</pre></div>
520</div>
521<p>The above examples would create a form similar to this:</p>
522<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="o">&lt;</span><span class="nx">form</span> <span class="nx">method</span><span class="o">=</span><span class="s2">&quot;post&quot;</span> <span class="nx">accept</span><span class="o">-</span><span class="nx">charset</span><span class="o">=</span><span class="s2">&quot;utf-8&quot;</span> <span class="nx">action</span><span class="o">=</span><span class="s2">&quot;http://example.com/index.php/email/send&quot;</span> <span class="nx">class</span><span class="o">=</span><span class="s2">&quot;email&quot;</span> <span class="nx">id</span><span class="o">=</span><span class="s2">&quot;myform&quot;</span><span class="o">&gt;</span>
523</pre></div>
524</div>
525</div></blockquote>
526<p><strong>Adding Hidden Input Fields</strong></p>
527<blockquote>
528<div><p>Hidden fields can be added by passing an associative array to the
529third parameter, like this:</p>
530<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$hidden</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span><span class="s1">&#39;username&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;Joe&#39;</span><span class="p">,</span> <span class="s1">&#39;member_id&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;234&#39;</span><span class="p">);</span>
531<span class="k">echo</span> <span class="nx">form_open</span><span class="p">(</span><span class="s1">&#39;email/send&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="nv">$hidden</span><span class="p">);</span>
532</pre></div>
533</div>
534<p>You can skip the second parameter by passing any falsy value to it.</p>
535<p>The above example would create a form similar to this:</p>
536<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="o">&lt;</span><span class="nx">form</span> <span class="nx">method</span><span class="o">=</span><span class="s2">&quot;post&quot;</span> <span class="nx">accept</span><span class="o">-</span><span class="nx">charset</span><span class="o">=</span><span class="s2">&quot;utf-8&quot;</span> <span class="nx">action</span><span class="o">=</span><span class="s2">&quot;http://example.com/index.php/email/send&quot;</span><span class="o">&gt;</span>
537 <span class="o">&lt;</span><span class="nx">input</span> <span class="nx">type</span><span class="o">=</span><span class="s2">&quot;hidden&quot;</span> <span class="nx">name</span><span class="o">=</span><span class="s2">&quot;username&quot;</span> <span class="nx">value</span><span class="o">=</span><span class="s2">&quot;Joe&quot;</span> <span class="o">/&gt;</span>
538 <span class="o">&lt;</span><span class="nx">input</span> <span class="nx">type</span><span class="o">=</span><span class="s2">&quot;hidden&quot;</span> <span class="nx">name</span><span class="o">=</span><span class="s2">&quot;member_id&quot;</span> <span class="nx">value</span><span class="o">=</span><span class="s2">&quot;234&quot;</span> <span class="o">/&gt;</span>
539</pre></div>
540</div>
541</div></blockquote>
542</dd></dl>
543
544<dl class="function">
545<dt id="form_open_multipart">
546<code class="descname">form_open_multipart</code><span class="sig-paren">(</span><span class="optional">[</span><em>$action = ''</em><span class="optional">[</span>, <em>$attributes = array()</em><span class="optional">[</span>, <em>$hidden = array()</em><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#form_open_multipart" title="Permalink to this definition"></a></dt>
547<dd><table class="docutils field-list" frame="void" rules="none">
548<col class="field-name" />
549<col class="field-body" />
550<tbody valign="top">
551<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
552<li><strong>$action</strong> (<em>string</em>) – Form action/target URI string</li>
553<li><strong>$attributes</strong> (<em>array</em>) – HTML attributes</li>
554<li><strong>$hidden</strong> (<em>array</em>) – An array of hidden fields’ definitions</li>
555</ul>
556</td>
557</tr>
558<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">An HTML multipart form opening tag</p>
559</td>
560</tr>
561<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p>
562</td>
563</tr>
564</tbody>
565</table>
566<p>This function is absolutely identical to <a class="reference internal" href="#form_open" title="form_open"><code class="xref php php-func docutils literal"><span class="pre">form_open()</span></code></a> above,
567except that it adds a <em>multipart</em> attribute, which is necessary if you
568would like to use the form to upload files with.</p>
569</dd></dl>
570
571<dl class="function">
572<dt id="form_hidden">
573<code class="descname">form_hidden</code><span class="sig-paren">(</span><em>$name</em><span class="optional">[</span>, <em>$value = ''</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#form_hidden" title="Permalink to this definition"></a></dt>
574<dd><table class="docutils field-list" frame="void" rules="none">
575<col class="field-name" />
576<col class="field-body" />
577<tbody valign="top">
578<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
579<li><strong>$name</strong> (<em>string</em>) – Field name</li>
580<li><strong>$value</strong> (<em>string</em>) – Field value</li>
581</ul>
582</td>
583</tr>
584<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">An HTML hidden input field tag</p>
585</td>
586</tr>
587<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p>
588</td>
589</tr>
590</tbody>
591</table>
592<p>Lets you generate hidden input fields. You can either submit a
593name/value string to create one field:</p>
594<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nx">form_hidden</span><span class="p">(</span><span class="s1">&#39;username&#39;</span><span class="p">,</span> <span class="s1">&#39;johndoe&#39;</span><span class="p">);</span>
595<span class="c1">// Would produce: &lt;input type=&quot;hidden&quot; name=&quot;username&quot; value=&quot;johndoe&quot; /&gt;</span>
596</pre></div>
597</div>
598<p>… or you can submit an associative array to create multiple fields:</p>
599<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$data</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span>
600 <span class="s1">&#39;name&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;John Doe&#39;</span><span class="p">,</span>
601 <span class="s1">&#39;email&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;john@example.com&#39;</span><span class="p">,</span>
602 <span class="s1">&#39;url&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;http://example.com&#39;</span>
603<span class="p">);</span>
604
605<span class="k">echo</span> <span class="nx">form_hidden</span><span class="p">(</span><span class="nv">$data</span><span class="p">);</span>
606
607<span class="cm">/*</span>
608<span class="cm"> Would produce:</span>
609<span class="cm"> &lt;input type=&quot;hidden&quot; name=&quot;name&quot; value=&quot;John Doe&quot; /&gt;</span>
610<span class="cm"> &lt;input type=&quot;hidden&quot; name=&quot;email&quot; value=&quot;john@example.com&quot; /&gt;</span>
611<span class="cm"> &lt;input type=&quot;hidden&quot; name=&quot;url&quot; value=&quot;http://example.com&quot; /&gt;</span>
612<span class="cm">*/</span>
613</pre></div>
614</div>
615<p>You can also pass an associative array to the value field:</p>
616<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$data</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span>
617 <span class="s1">&#39;name&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;John Doe&#39;</span><span class="p">,</span>
618 <span class="s1">&#39;email&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;john@example.com&#39;</span><span class="p">,</span>
619 <span class="s1">&#39;url&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;http://example.com&#39;</span>
620<span class="p">);</span>
621
622<span class="k">echo</span> <span class="nx">form_hidden</span><span class="p">(</span><span class="s1">&#39;my_array&#39;</span><span class="p">,</span> <span class="nv">$data</span><span class="p">);</span>
623
624<span class="cm">/*</span>
625<span class="cm"> Would produce:</span>
626
627<span class="cm"> &lt;input type=&quot;hidden&quot; name=&quot;my_array[name]&quot; value=&quot;John Doe&quot; /&gt;</span>
628<span class="cm"> &lt;input type=&quot;hidden&quot; name=&quot;my_array[email]&quot; value=&quot;john@example.com&quot; /&gt;</span>
629<span class="cm"> &lt;input type=&quot;hidden&quot; name=&quot;my_array[url]&quot; value=&quot;http://example.com&quot; /&gt;</span>
630<span class="cm">*/</span>
631</pre></div>
632</div>
633<p>If you want to create hidden input fields with extra attributes:</p>
634<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$data</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span>
635 <span class="s1">&#39;type&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;hidden&#39;</span><span class="p">,</span>
636 <span class="s1">&#39;name&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;email&#39;</span><span class="p">,</span>
637 <span class="s1">&#39;id&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;hiddenemail&#39;</span><span class="p">,</span>
638 <span class="s1">&#39;value&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;john@example.com&#39;</span><span class="p">,</span>
639 <span class="s1">&#39;class&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;hiddenemail&#39;</span>
640<span class="p">);</span>
641
642<span class="k">echo</span> <span class="nx">form_input</span><span class="p">(</span><span class="nv">$data</span><span class="p">);</span>
643
644<span class="cm">/*</span>
645<span class="cm"> Would produce:</span>
646
647<span class="cm"> &lt;input type=&quot;hidden&quot; name=&quot;email&quot; value=&quot;john@example.com&quot; id=&quot;hiddenemail&quot; class=&quot;hiddenemail&quot; /&gt;</span>
648<span class="cm">*/</span>
649</pre></div>
650</div>
651</dd></dl>
652
653<dl class="function">
654<dt id="form_input">
655<code class="descname">form_input</code><span class="sig-paren">(</span><span class="optional">[</span><em>$data = ''</em><span class="optional">[</span>, <em>$value = ''</em><span class="optional">[</span>, <em>$extra = ''</em><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#form_input" title="Permalink to this definition"></a></dt>
656<dd><table class="docutils field-list" frame="void" rules="none">
657<col class="field-name" />
658<col class="field-body" />
659<tbody valign="top">
660<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
661<li><strong>$data</strong> (<em>array</em>) – Field attributes data</li>
662<li><strong>$value</strong> (<em>string</em>) – Field value</li>
663<li><strong>$extra</strong> (<em>mixed</em>) – Extra attributes to be added to the tag either as an array or a literal string</li>
664</ul>
665</td>
666</tr>
667<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">An HTML text input field tag</p>
668</td>
669</tr>
670<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p>
671</td>
672</tr>
673</tbody>
674</table>
675<p>Lets you generate a standard text input field. You can minimally pass
676the field name and value in the first and second parameter:</p>
677<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">echo</span> <span class="nx">form_input</span><span class="p">(</span><span class="s1">&#39;username&#39;</span><span class="p">,</span> <span class="s1">&#39;johndoe&#39;</span><span class="p">);</span>
678</pre></div>
679</div>
680<p>Or you can pass an associative array containing any data you wish your
681form to contain:</p>
682<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$data</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span>
683 <span class="s1">&#39;name&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;username&#39;</span><span class="p">,</span>
684 <span class="s1">&#39;id&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;username&#39;</span><span class="p">,</span>
685 <span class="s1">&#39;value&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;johndoe&#39;</span><span class="p">,</span>
686 <span class="s1">&#39;maxlength&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;100&#39;</span><span class="p">,</span>
687 <span class="s1">&#39;size&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;50&#39;</span><span class="p">,</span>
688 <span class="s1">&#39;style&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;width:50%&#39;</span>
689<span class="p">);</span>
690
691<span class="k">echo</span> <span class="nx">form_input</span><span class="p">(</span><span class="nv">$data</span><span class="p">);</span>
692
693<span class="cm">/*</span>
694<span class="cm"> Would produce:</span>
695
696<span class="cm"> &lt;input type=&quot;text&quot; name=&quot;username&quot; value=&quot;johndoe&quot; id=&quot;username&quot; maxlength=&quot;100&quot; size=&quot;50&quot; style=&quot;width:50%&quot; /&gt;</span>
697<span class="cm">*/</span>
698</pre></div>
699</div>
700<p>If you would like your form to contain some additional data, like
701JavaScript, you can pass it as a string in the third parameter:</p>
702<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$js</span> <span class="o">=</span> <span class="s1">&#39;onClick=&quot;some_function()&quot;&#39;</span><span class="p">;</span>
703<span class="k">echo</span> <span class="nx">form_input</span><span class="p">(</span><span class="s1">&#39;username&#39;</span><span class="p">,</span> <span class="s1">&#39;johndoe&#39;</span><span class="p">,</span> <span class="nv">$js</span><span class="p">);</span>
704</pre></div>
705</div>
706<p>Or you can pass it as an array:</p>
707<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$js</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span><span class="s1">&#39;onClick&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;some_function();&#39;</span><span class="p">);</span>
708<span class="k">echo</span> <span class="nx">form_input</span><span class="p">(</span><span class="s1">&#39;username&#39;</span><span class="p">,</span> <span class="s1">&#39;johndoe&#39;</span><span class="p">,</span> <span class="nv">$js</span><span class="p">);</span>
709</pre></div>
710</div>
711</dd></dl>
712
713<dl class="function">
714<dt id="form_password">
715<code class="descname">form_password</code><span class="sig-paren">(</span><span class="optional">[</span><em>$data = ''</em><span class="optional">[</span>, <em>$value = ''</em><span class="optional">[</span>, <em>$extra = ''</em><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#form_password" title="Permalink to this definition"></a></dt>
716<dd><table class="docutils field-list" frame="void" rules="none">
717<col class="field-name" />
718<col class="field-body" />
719<tbody valign="top">
720<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
721<li><strong>$data</strong> (<em>array</em>) – Field attributes data</li>
722<li><strong>$value</strong> (<em>string</em>) – Field value</li>
723<li><strong>$extra</strong> (<em>mixed</em>) – Extra attributes to be added to the tag either as an array or a literal string</li>
724</ul>
725</td>
726</tr>
727<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">An HTML password input field tag</p>
728</td>
729</tr>
730<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p>
731</td>
732</tr>
733</tbody>
734</table>
735<p>This function is identical in all respects to the <a class="reference internal" href="#form_input" title="form_input"><code class="xref php php-func docutils literal"><span class="pre">form_input()</span></code></a>
736function above except that it uses the “password” input type.</p>
737</dd></dl>
738
739<dl class="function">
740<dt id="form_upload">
741<code class="descname">form_upload</code><span class="sig-paren">(</span><span class="optional">[</span><em>$data = ''</em><span class="optional">[</span>, <em>$value = ''</em><span class="optional">[</span>, <em>$extra = ''</em><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#form_upload" title="Permalink to this definition"></a></dt>
742<dd><table class="docutils field-list" frame="void" rules="none">
743<col class="field-name" />
744<col class="field-body" />
745<tbody valign="top">
746<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
747<li><strong>$data</strong> (<em>array</em>) – Field attributes data</li>
748<li><strong>$value</strong> (<em>string</em>) – Field value</li>
749<li><strong>$extra</strong> (<em>mixed</em>) – Extra attributes to be added to the tag either as an array or a literal string</li>
750</ul>
751</td>
752</tr>
753<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">An HTML file upload input field tag</p>
754</td>
755</tr>
756<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p>
757</td>
758</tr>
759</tbody>
760</table>
761<p>This function is identical in all respects to the <a class="reference internal" href="#form_input" title="form_input"><code class="xref php php-func docutils literal"><span class="pre">form_input()</span></code></a>
762function above except that it uses the “file” input type, allowing it to
763be used to upload files.</p>
764</dd></dl>
765
766<dl class="function">
767<dt id="form_textarea">
768<code class="descname">form_textarea</code><span class="sig-paren">(</span><span class="optional">[</span><em>$data = ''</em><span class="optional">[</span>, <em>$value = ''</em><span class="optional">[</span>, <em>$extra = ''</em><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#form_textarea" title="Permalink to this definition"></a></dt>
769<dd><table class="docutils field-list" frame="void" rules="none">
770<col class="field-name" />
771<col class="field-body" />
772<tbody valign="top">
773<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
774<li><strong>$data</strong> (<em>array</em>) – Field attributes data</li>
775<li><strong>$value</strong> (<em>string</em>) – Field value</li>
776<li><strong>$extra</strong> (<em>mixed</em>) – Extra attributes to be added to the tag either as an array or a literal string</li>
777</ul>
778</td>
779</tr>
780<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">An HTML textarea tag</p>
781</td>
782</tr>
783<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p>
784</td>
785</tr>
786</tbody>
787</table>
788<p>This function is identical in all respects to the <a class="reference internal" href="#form_input" title="form_input"><code class="xref php php-func docutils literal"><span class="pre">form_input()</span></code></a>
789function above except that it generates a “textarea” type.</p>
790<div class="admonition note">
791<p class="first admonition-title">Note</p>
792<p class="last">Instead of the <em>maxlength</em> and <em>size</em> attributes in the above example,
793you will instead specify <em>rows</em> and <em>cols</em>.</p>
794</div>
795</dd></dl>
796
797<dl class="function">
798<dt id="form_dropdown">
799<code class="descname">form_dropdown</code><span class="sig-paren">(</span><span class="optional">[</span><em>$name = ''</em><span class="optional">[</span>, <em>$options = array()</em><span class="optional">[</span>, <em>$selected = array()</em><span class="optional">[</span>, <em>$extra = ''</em><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#form_dropdown" title="Permalink to this definition"></a></dt>
800<dd><table class="docutils field-list" frame="void" rules="none">
801<col class="field-name" />
802<col class="field-body" />
803<tbody valign="top">
804<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
805<li><strong>$name</strong> (<em>string</em>) – Field name</li>
806<li><strong>$options</strong> (<em>array</em>) – An associative array of options to be listed</li>
807<li><strong>$selected</strong> (<em>array</em>) – List of fields to mark with the <em>selected</em> attribute</li>
808<li><strong>$extra</strong> (<em>mixed</em>) – Extra attributes to be added to the tag either as an array or a literal string</li>
809</ul>
810</td>
811</tr>
812<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">An HTML dropdown select field tag</p>
813</td>
814</tr>
815<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p>
816</td>
817</tr>
818</tbody>
819</table>
820<p>Lets you create a standard drop-down field. The first parameter will
821contain the name of the field, the second parameter will contain an
822associative array of options, and the third parameter will contain the
823value you wish to be selected. You can also pass an array of multiple
824items through the third parameter, and CodeIgniter will create a
825multiple select for you.</p>
826<p>Example:</p>
827<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$options</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span>
828 <span class="s1">&#39;small&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;Small Shirt&#39;</span><span class="p">,</span>
829 <span class="s1">&#39;med&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;Medium Shirt&#39;</span><span class="p">,</span>
830 <span class="s1">&#39;large&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;Large Shirt&#39;</span><span class="p">,</span>
831 <span class="s1">&#39;xlarge&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;Extra Large Shirt&#39;</span><span class="p">,</span>
832<span class="p">);</span>
833
834<span class="nv">$shirts_on_sale</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span><span class="s1">&#39;small&#39;</span><span class="p">,</span> <span class="s1">&#39;large&#39;</span><span class="p">);</span>
835<span class="k">echo</span> <span class="nx">form_dropdown</span><span class="p">(</span><span class="s1">&#39;shirts&#39;</span><span class="p">,</span> <span class="nv">$options</span><span class="p">,</span> <span class="s1">&#39;large&#39;</span><span class="p">);</span>
836
837<span class="cm">/*</span>
838<span class="cm"> Would produce:</span>
839
840<span class="cm"> &lt;select name=&quot;shirts&quot;&gt;</span>
841<span class="cm"> &lt;option value=&quot;small&quot;&gt;Small Shirt&lt;/option&gt;</span>
842<span class="cm"> &lt;option value=&quot;med&quot;&gt;Medium Shirt&lt;/option&gt;</span>
843<span class="cm"> &lt;option value=&quot;large&quot; selected=&quot;selected&quot;&gt;Large Shirt&lt;/option&gt;</span>
844<span class="cm"> &lt;option value=&quot;xlarge&quot;&gt;Extra Large Shirt&lt;/option&gt;</span>
845<span class="cm"> &lt;/select&gt;</span>
846<span class="cm">*/</span>
847
848<span class="k">echo</span> <span class="nx">form_dropdown</span><span class="p">(</span><span class="s1">&#39;shirts&#39;</span><span class="p">,</span> <span class="nv">$options</span><span class="p">,</span> <span class="nv">$shirts_on_sale</span><span class="p">);</span>
849
850<span class="cm">/*</span>
851<span class="cm"> Would produce:</span>
852
853<span class="cm"> &lt;select name=&quot;shirts&quot; multiple=&quot;multiple&quot;&gt;</span>
854<span class="cm"> &lt;option value=&quot;small&quot; selected=&quot;selected&quot;&gt;Small Shirt&lt;/option&gt;</span>
855<span class="cm"> &lt;option value=&quot;med&quot;&gt;Medium Shirt&lt;/option&gt;</span>
856<span class="cm"> &lt;option value=&quot;large&quot; selected=&quot;selected&quot;&gt;Large Shirt&lt;/option&gt;</span>
857<span class="cm"> &lt;option value=&quot;xlarge&quot;&gt;Extra Large Shirt&lt;/option&gt;</span>
858<span class="cm"> &lt;/select&gt;</span>
859<span class="cm">*/</span>
860</pre></div>
861</div>
862<p>If you would like the opening &lt;select&gt; to contain additional data, like
863an id attribute or JavaScript, you can pass it as a string in the fourth
864parameter:</p>
865<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$js</span> <span class="o">=</span> <span class="s1">&#39;id=&quot;shirts&quot; onChange=&quot;some_function();&quot;&#39;</span><span class="p">;</span>
866<span class="k">echo</span> <span class="nx">form_dropdown</span><span class="p">(</span><span class="s1">&#39;shirts&#39;</span><span class="p">,</span> <span class="nv">$options</span><span class="p">,</span> <span class="s1">&#39;large&#39;</span><span class="p">,</span> <span class="nv">$js</span><span class="p">);</span>
867</pre></div>
868</div>
869<p>Or you can pass it as an array:</p>
870<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$js</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span>
871 <span class="s1">&#39;id&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;shirts&#39;</span><span class="p">,</span>
872 <span class="s1">&#39;onChange&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;some_function();&#39;</span>
873<span class="p">);</span>
874<span class="k">echo</span> <span class="nx">form_dropdown</span><span class="p">(</span><span class="s1">&#39;shirts&#39;</span><span class="p">,</span> <span class="nv">$options</span><span class="p">,</span> <span class="s1">&#39;large&#39;</span><span class="p">,</span> <span class="nv">$js</span><span class="p">);</span>
875</pre></div>
876</div>
877<p>If the array passed as <code class="docutils literal"><span class="pre">$options</span></code> is a multidimensional array, then
878<code class="docutils literal"><span class="pre">form_dropdown()</span></code> will produce an &lt;optgroup&gt; with the array key as the
879label.</p>
880</dd></dl>
881
882<dl class="function">
883<dt id="form_multiselect">
884<code class="descname">form_multiselect</code><span class="sig-paren">(</span><span class="optional">[</span><em>$name = ''</em><span class="optional">[</span>, <em>$options = array()</em><span class="optional">[</span>, <em>$selected = array()</em><span class="optional">[</span>, <em>$extra = ''</em><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#form_multiselect" title="Permalink to this definition"></a></dt>
885<dd><table class="docutils field-list" frame="void" rules="none">
886<col class="field-name" />
887<col class="field-body" />
888<tbody valign="top">
889<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
890<li><strong>$name</strong> (<em>string</em>) – Field name</li>
891<li><strong>$options</strong> (<em>array</em>) – An associative array of options to be listed</li>
892<li><strong>$selected</strong> (<em>array</em>) – List of fields to mark with the <em>selected</em> attribute</li>
893<li><strong>$extra</strong> (<em>mixed</em>) – Extra attributes to be added to the tag either as an array or a literal string</li>
894</ul>
895</td>
896</tr>
897<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">An HTML dropdown multiselect field tag</p>
898</td>
899</tr>
900<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p>
901</td>
902</tr>
903</tbody>
904</table>
905<p>Lets you create a standard multiselect field. The first parameter will
906contain the name of the field, the second parameter will contain an
907associative array of options, and the third parameter will contain the
908value or values you wish to be selected.</p>
909<p>The parameter usage is identical to using <a class="reference internal" href="#form_dropdown" title="form_dropdown"><code class="xref php php-func docutils literal"><span class="pre">form_dropdown()</span></code></a> above,
910except of course that the name of the field will need to use POST array
911syntax, e.g. foo[].</p>
912</dd></dl>
913
914<dl class="function">
915<dt id="form_fieldset">
916<code class="descname">form_fieldset</code><span class="sig-paren">(</span><span class="optional">[</span><em>$legend_text = ''</em><span class="optional">[</span>, <em>$attributes = array()</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#form_fieldset" title="Permalink to this definition"></a></dt>
917<dd><table class="docutils field-list" frame="void" rules="none">
918<col class="field-name" />
919<col class="field-body" />
920<tbody valign="top">
921<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
922<li><strong>$legend_text</strong> (<em>string</em>) – Text to put in the &lt;legend&gt; tag</li>
923<li><strong>$attributes</strong> (<em>array</em>) – Attributes to be set on the &lt;fieldset&gt; tag</li>
924</ul>
925</td>
926</tr>
927<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">An HTML fieldset opening tag</p>
928</td>
929</tr>
930<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p>
931</td>
932</tr>
933</tbody>
934</table>
935<p>Lets you generate fieldset/legend fields.</p>
936<p>Example:</p>
937<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">echo</span> <span class="nx">form_fieldset</span><span class="p">(</span><span class="s1">&#39;Address Information&#39;</span><span class="p">);</span>
938<span class="k">echo</span> <span class="s2">&quot;&lt;p&gt;fieldset content here&lt;/p&gt;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">;</span>
939<span class="k">echo</span> <span class="nx">form_fieldset_close</span><span class="p">();</span>
940
941<span class="cm">/*</span>
942<span class="cm"> Produces:</span>
943
944<span class="cm"> &lt;fieldset&gt;</span>
945<span class="cm"> &lt;legend&gt;Address Information&lt;/legend&gt;</span>
946<span class="cm"> &lt;p&gt;form content here&lt;/p&gt;</span>
947<span class="cm"> &lt;/fieldset&gt;</span>
948<span class="cm">*/</span>
949</pre></div>
950</div>
951<p>Similar to other functions, you can submit an associative array in the
952second parameter if you prefer to set additional attributes:</p>
953<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$attributes</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span>
954 <span class="s1">&#39;id&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;address_info&#39;</span><span class="p">,</span>
955 <span class="s1">&#39;class&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;address_info&#39;</span>
956<span class="p">);</span>
957
958<span class="k">echo</span> <span class="nx">form_fieldset</span><span class="p">(</span><span class="s1">&#39;Address Information&#39;</span><span class="p">,</span> <span class="nv">$attributes</span><span class="p">);</span>
959<span class="k">echo</span> <span class="s2">&quot;&lt;p&gt;fieldset content here&lt;/p&gt;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">;</span>
960<span class="k">echo</span> <span class="nx">form_fieldset_close</span><span class="p">();</span>
961
962<span class="cm">/*</span>
963<span class="cm"> Produces:</span>
964
965<span class="cm"> &lt;fieldset id=&quot;address_info&quot; class=&quot;address_info&quot;&gt;</span>
966<span class="cm"> &lt;legend&gt;Address Information&lt;/legend&gt;</span>
967<span class="cm"> &lt;p&gt;form content here&lt;/p&gt;</span>
968<span class="cm"> &lt;/fieldset&gt;</span>
969<span class="cm">*/</span>
970</pre></div>
971</div>
972</dd></dl>
973
974<dl class="function">
975<dt id="form_fieldset_close">
976<code class="descname">form_fieldset_close</code><span class="sig-paren">(</span><span class="optional">[</span><em>$extra = ''</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#form_fieldset_close" title="Permalink to this definition"></a></dt>
977<dd><table class="docutils field-list" frame="void" rules="none">
978<col class="field-name" />
979<col class="field-body" />
980<tbody valign="top">
981<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
982<li><strong>$extra</strong> (<em>string</em>) – Anything to append after the closing tag, <em>as is</em></li>
983</ul>
984</td>
985</tr>
986<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">An HTML fieldset closing tag</p>
987</td>
988</tr>
989<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p>
990</td>
991</tr>
992</tbody>
993</table>
994<p>Produces a closing &lt;/fieldset&gt; tag. The only advantage to using this
995function is it permits you to pass data to it which will be added below
996the tag. For example</p>
997<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$string</span> <span class="o">=</span> <span class="s1">&#39;&lt;/div&gt;&lt;/div&gt;&#39;</span><span class="p">;</span>
998<span class="k">echo</span> <span class="nx">form_fieldset_close</span><span class="p">(</span><span class="nv">$string</span><span class="p">);</span>
999<span class="c1">// Would produce: &lt;/fieldset&gt;&lt;/div&gt;&lt;/div&gt;</span>
1000</pre></div>
1001</div>
1002</dd></dl>
1003
1004<dl class="function">
1005<dt id="form_checkbox">
1006<code class="descname">form_checkbox</code><span class="sig-paren">(</span><span class="optional">[</span><em>$data = ''</em><span class="optional">[</span>, <em>$value = ''</em><span class="optional">[</span>, <em>$checked = FALSE</em><span class="optional">[</span>, <em>$extra = ''</em><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#form_checkbox" title="Permalink to this definition"></a></dt>
1007<dd><table class="docutils field-list" frame="void" rules="none">
1008<col class="field-name" />
1009<col class="field-body" />
1010<tbody valign="top">
1011<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
1012<li><strong>$data</strong> (<em>array</em>) – Field attributes data</li>
1013<li><strong>$value</strong> (<em>string</em>) – Field value</li>
1014<li><strong>$checked</strong> (<em>bool</em>) – Whether to mark the checkbox as being <em>checked</em></li>
1015<li><strong>$extra</strong> (<em>mixed</em>) – Extra attributes to be added to the tag either as an array or a literal string</li>
1016</ul>
1017</td>
1018</tr>
1019<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">An HTML checkbox input tag</p>
1020</td>
1021</tr>
1022<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p>
1023</td>
1024</tr>
1025</tbody>
1026</table>
1027<p>Lets you generate a checkbox field. Simple example:</p>
1028<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">echo</span> <span class="nx">form_checkbox</span><span class="p">(</span><span class="s1">&#39;newsletter&#39;</span><span class="p">,</span> <span class="s1">&#39;accept&#39;</span><span class="p">,</span> <span class="k">TRUE</span><span class="p">);</span>
1029<span class="c1">// Would produce: &lt;input type=&quot;checkbox&quot; name=&quot;newsletter&quot; value=&quot;accept&quot; checked=&quot;checked&quot; /&gt;</span>
1030</pre></div>
1031</div>
1032<p>The third parameter contains a boolean TRUE/FALSE to determine whether
1033the box should be checked or not.</p>
1034<p>Similar to the other form functions in this helper, you can also pass an
1035array of attributes to the function:</p>
1036<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$data</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span>
1037 <span class="s1">&#39;name&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;newsletter&#39;</span><span class="p">,</span>
1038 <span class="s1">&#39;id&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;newsletter&#39;</span><span class="p">,</span>
1039 <span class="s1">&#39;value&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;accept&#39;</span><span class="p">,</span>
1040 <span class="s1">&#39;checked&#39;</span> <span class="o">=&gt;</span> <span class="k">TRUE</span><span class="p">,</span>
1041 <span class="s1">&#39;style&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;margin:10px&#39;</span>
1042<span class="p">);</span>
1043
1044<span class="k">echo</span> <span class="nx">form_checkbox</span><span class="p">(</span><span class="nv">$data</span><span class="p">);</span>
1045<span class="c1">// Would produce: &lt;input type=&quot;checkbox&quot; name=&quot;newsletter&quot; id=&quot;newsletter&quot; value=&quot;accept&quot; checked=&quot;checked&quot; style=&quot;margin:10px&quot; /&gt;</span>
1046</pre></div>
1047</div>
1048<p>Also as with other functions, if you would like the tag to contain
1049additional data like JavaScript, you can pass it as a string in the
1050fourth parameter:</p>
1051<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$js</span> <span class="o">=</span> <span class="s1">&#39;onClick=&quot;some_function()&quot;&#39;</span><span class="p">;</span>
1052<span class="k">echo</span> <span class="nx">form_checkbox</span><span class="p">(</span><span class="s1">&#39;newsletter&#39;</span><span class="p">,</span> <span class="s1">&#39;accept&#39;</span><span class="p">,</span> <span class="k">TRUE</span><span class="p">,</span> <span class="nv">$js</span><span class="p">);</span>
1053</pre></div>
1054</div>
1055<p>Or you can pass it as an array:</p>
1056<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$js</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span><span class="s1">&#39;onClick&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;some_function();&#39;</span><span class="p">);</span>
1057<span class="k">echo</span> <span class="nx">form_checkbox</span><span class="p">(</span><span class="s1">&#39;newsletter&#39;</span><span class="p">,</span> <span class="s1">&#39;accept&#39;</span><span class="p">,</span> <span class="k">TRUE</span><span class="p">,</span> <span class="nv">$js</span><span class="p">);</span>
1058</pre></div>
1059</div>
1060</dd></dl>
1061
1062<dl class="function">
1063<dt id="form_radio">
1064<code class="descname">form_radio</code><span class="sig-paren">(</span><span class="optional">[</span><em>$data = ''</em><span class="optional">[</span>, <em>$value = ''</em><span class="optional">[</span>, <em>$checked = FALSE</em><span class="optional">[</span>, <em>$extra = ''</em><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#form_radio" title="Permalink to this definition"></a></dt>
1065<dd><table class="docutils field-list" frame="void" rules="none">
1066<col class="field-name" />
1067<col class="field-body" />
1068<tbody valign="top">
1069<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
1070<li><strong>$data</strong> (<em>array</em>) – Field attributes data</li>
1071<li><strong>$value</strong> (<em>string</em>) – Field value</li>
1072<li><strong>$checked</strong> (<em>bool</em>) – Whether to mark the radio button as being <em>checked</em></li>
1073<li><strong>$extra</strong> (<em>mixed</em>) – Extra attributes to be added to the tag either as an array or a literal string</li>
1074</ul>
1075</td>
1076</tr>
1077<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">An HTML radio input tag</p>
1078</td>
1079</tr>
1080<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p>
1081</td>
1082</tr>
1083</tbody>
1084</table>
1085<p>This function is identical in all respects to the <a class="reference internal" href="#form_checkbox" title="form_checkbox"><code class="xref php php-func docutils literal"><span class="pre">form_checkbox()</span></code></a>
1086function above except that it uses the “radio” input type.</p>
1087</dd></dl>
1088
1089<dl class="function">
1090<dt id="form_label">
1091<code class="descname">form_label</code><span class="sig-paren">(</span><span class="optional">[</span><em>$label_text = ''</em><span class="optional">[</span>, <em>$id = ''</em><span class="optional">[</span>, <em>$attributes = array()</em><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#form_label" title="Permalink to this definition"></a></dt>
1092<dd><table class="docutils field-list" frame="void" rules="none">
1093<col class="field-name" />
1094<col class="field-body" />
1095<tbody valign="top">
1096<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
1097<li><strong>$label_text</strong> (<em>string</em>) – Text to put in the &lt;label&gt; tag</li>
1098<li><strong>$id</strong> (<em>string</em>) – ID of the form element that we’re making a label for</li>
1099<li><strong>$attributes</strong> (<em>mixed</em>) – HTML attributes</li>
1100</ul>
1101</td>
1102</tr>
1103<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">An HTML field label tag</p>
1104</td>
1105</tr>
1106<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p>
1107</td>
1108</tr>
1109</tbody>
1110</table>
1111<p>Lets you generate a &lt;label&gt;. Simple example:</p>
1112<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">echo</span> <span class="nx">form_label</span><span class="p">(</span><span class="s1">&#39;What is your Name&#39;</span><span class="p">,</span> <span class="s1">&#39;username&#39;</span><span class="p">);</span>
1113<span class="c1">// Would produce: &lt;label for=&quot;username&quot;&gt;What is your Name&lt;/label&gt;</span>
1114</pre></div>
1115</div>
1116<p>Similar to other functions, you can submit an associative array in the
1117third parameter if you prefer to set additional attributes.</p>
1118<p>Example:</p>
1119<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$attributes</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span>
1120 <span class="s1">&#39;class&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;mycustomclass&#39;</span><span class="p">,</span>
1121 <span class="s1">&#39;style&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;color: #000;&#39;</span>
1122<span class="p">);</span>
1123
1124<span class="k">echo</span> <span class="nx">form_label</span><span class="p">(</span><span class="s1">&#39;What is your Name&#39;</span><span class="p">,</span> <span class="s1">&#39;username&#39;</span><span class="p">,</span> <span class="nv">$attributes</span><span class="p">);</span>
1125<span class="c1">// Would produce: &lt;label for=&quot;username&quot; class=&quot;mycustomclass&quot; style=&quot;color: #000;&quot;&gt;What is your Name&lt;/label&gt;</span>
1126</pre></div>
1127</div>
1128</dd></dl>
1129
1130<dl class="function">
1131<dt id="form_submit">
1132<code class="descname">form_submit</code><span class="sig-paren">(</span><span class="optional">[</span><em>$data = ''</em><span class="optional">[</span>, <em>$value = ''</em><span class="optional">[</span>, <em>$extra = ''</em><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#form_submit" title="Permalink to this definition"></a></dt>
1133<dd><table class="docutils field-list" frame="void" rules="none">
1134<col class="field-name" />
1135<col class="field-body" />
1136<tbody valign="top">
1137<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
1138<li><strong>$data</strong> (<em>string</em>) – Button name</li>
1139<li><strong>$value</strong> (<em>string</em>) – Button value</li>
1140<li><strong>$extra</strong> (<em>mixed</em>) – Extra attributes to be added to the tag either as an array or a literal string</li>
1141</ul>
1142</td>
1143</tr>
1144<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">An HTML input submit tag</p>
1145</td>
1146</tr>
1147<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p>
1148</td>
1149</tr>
1150</tbody>
1151</table>
1152<p>Lets you generate a standard submit button. Simple example:</p>
1153<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">echo</span> <span class="nx">form_submit</span><span class="p">(</span><span class="s1">&#39;mysubmit&#39;</span><span class="p">,</span> <span class="s1">&#39;Submit Post!&#39;</span><span class="p">);</span>
1154<span class="c1">// Would produce: &lt;input type=&quot;submit&quot; name=&quot;mysubmit&quot; value=&quot;Submit Post!&quot; /&gt;</span>
1155</pre></div>
1156</div>
1157<p>Similar to other functions, you can submit an associative array in the
1158first parameter if you prefer to set your own attributes. The third
1159parameter lets you add extra data to your form, like JavaScript.</p>
1160</dd></dl>
1161
1162<dl class="function">
1163<dt id="form_reset">
1164<code class="descname">form_reset</code><span class="sig-paren">(</span><span class="optional">[</span><em>$data = ''</em><span class="optional">[</span>, <em>$value = ''</em><span class="optional">[</span>, <em>$extra = ''</em><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#form_reset" title="Permalink to this definition"></a></dt>
1165<dd><table class="docutils field-list" frame="void" rules="none">
1166<col class="field-name" />
1167<col class="field-body" />
1168<tbody valign="top">
1169<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
1170<li><strong>$data</strong> (<em>string</em>) – Button name</li>
1171<li><strong>$value</strong> (<em>string</em>) – Button value</li>
1172<li><strong>$extra</strong> (<em>mixed</em>) – Extra attributes to be added to the tag either as an array or a literal string</li>
1173</ul>
1174</td>
1175</tr>
1176<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">An HTML input reset button tag</p>
1177</td>
1178</tr>
1179<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p>
1180</td>
1181</tr>
1182</tbody>
1183</table>
1184<p>Lets you generate a standard reset button. Use is identical to
1185<code class="xref py py-func docutils literal"><span class="pre">form_submit()</span></code>.</p>
1186</dd></dl>
1187
1188<dl class="function">
1189<dt id="form_button">
1190<code class="descname">form_button</code><span class="sig-paren">(</span><span class="optional">[</span><em>$data = ''</em><span class="optional">[</span>, <em>$content = ''</em><span class="optional">[</span>, <em>$extra = ''</em><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#form_button" title="Permalink to this definition"></a></dt>
1191<dd><table class="docutils field-list" frame="void" rules="none">
1192<col class="field-name" />
1193<col class="field-body" />
1194<tbody valign="top">
1195<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
1196<li><strong>$data</strong> (<em>string</em>) – Button name</li>
1197<li><strong>$content</strong> (<em>string</em>) – Button label</li>
1198<li><strong>$extra</strong> (<em>mixed</em>) – Extra attributes to be added to the tag either as an array or a literal string</li>
1199</ul>
1200</td>
1201</tr>
1202<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">An HTML button tag</p>
1203</td>
1204</tr>
1205<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p>
1206</td>
1207</tr>
1208</tbody>
1209</table>
1210<p>Lets you generate a standard button element. You can minimally pass the
1211button name and content in the first and second parameter:</p>
1212<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">echo</span> <span class="nx">form_button</span><span class="p">(</span><span class="s1">&#39;name&#39;</span><span class="p">,</span><span class="s1">&#39;content&#39;</span><span class="p">);</span>
1213<span class="c1">// Would produce: &lt;button name=&quot;name&quot; type=&quot;button&quot;&gt;Content&lt;/button&gt;</span>
1214</pre></div>
1215</div>
1216<p>Or you can pass an associative array containing any data you wish your
1217form to contain:</p>
1218<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$data</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span>
1219 <span class="s1">&#39;name&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;button&#39;</span><span class="p">,</span>
1220 <span class="s1">&#39;id&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;button&#39;</span><span class="p">,</span>
1221 <span class="s1">&#39;value&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;true&#39;</span><span class="p">,</span>
1222 <span class="s1">&#39;type&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;reset&#39;</span><span class="p">,</span>
1223 <span class="s1">&#39;content&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;Reset&#39;</span>
1224<span class="p">);</span>
1225
1226<span class="k">echo</span> <span class="nx">form_button</span><span class="p">(</span><span class="nv">$data</span><span class="p">);</span>
1227<span class="c1">// Would produce: &lt;button name=&quot;button&quot; id=&quot;button&quot; value=&quot;true&quot; type=&quot;reset&quot;&gt;Reset&lt;/button&gt;</span>
1228</pre></div>
1229</div>
1230<p>If you would like your form to contain some additional data, like
1231JavaScript, you can pass it as a string in the third parameter:</p>
1232<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$js</span> <span class="o">=</span> <span class="s1">&#39;onClick=&quot;some_function()&quot;&#39;</span><span class="p">;</span>
1233<span class="k">echo</span> <span class="nx">form_button</span><span class="p">(</span><span class="s1">&#39;mybutton&#39;</span><span class="p">,</span> <span class="s1">&#39;Click Me&#39;</span><span class="p">,</span> <span class="nv">$js</span><span class="p">);</span>
1234</pre></div>
1235</div>
1236</dd></dl>
1237
1238<dl class="function">
1239<dt id="form_close">
1240<code class="descname">form_close</code><span class="sig-paren">(</span><span class="optional">[</span><em>$extra = ''</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#form_close" title="Permalink to this definition"></a></dt>
1241<dd><table class="docutils field-list" frame="void" rules="none">
1242<col class="field-name" />
1243<col class="field-body" />
1244<tbody valign="top">
1245<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
1246<li><strong>$extra</strong> (<em>string</em>) – Anything to append after the closing tag, <em>as is</em></li>
1247</ul>
1248</td>
1249</tr>
1250<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">An HTML form closing tag</p>
1251</td>
1252</tr>
1253<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p>
1254</td>
1255</tr>
1256</tbody>
1257</table>
1258<p>Produces a closing &lt;/form&gt; tag. The only advantage to using this
1259function is it permits you to pass data to it which will be added below
1260the tag. For example:</p>
1261<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$string</span> <span class="o">=</span> <span class="s1">&#39;&lt;/div&gt;&lt;/div&gt;&#39;</span><span class="p">;</span>
1262<span class="k">echo</span> <span class="nx">form_close</span><span class="p">(</span><span class="nv">$string</span><span class="p">);</span>
1263<span class="c1">// Would produce: &lt;/form&gt; &lt;/div&gt;&lt;/div&gt;</span>
1264</pre></div>
1265</div>
1266</dd></dl>
1267
1268<dl class="function">
1269<dt id="set_value">
1270<code class="descname">set_value</code><span class="sig-paren">(</span><em>$field</em><span class="optional">[</span>, <em>$default = ''</em><span class="optional">[</span>, <em>$html_escape = TRUE</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#set_value" title="Permalink to this definition"></a></dt>
1271<dd><table class="docutils field-list" frame="void" rules="none">
1272<col class="field-name" />
1273<col class="field-body" />
1274<tbody valign="top">
1275<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
1276<li><strong>$field</strong> (<em>string</em>) – Field name</li>
1277<li><strong>$default</strong> (<em>string</em>) – Default value</li>
1278<li><strong>$html_escape</strong> (<em>bool</em>) – Whether to turn off HTML escaping of the value</li>
1279</ul>
1280</td>
1281</tr>
1282<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Field value</p>
1283</td>
1284</tr>
1285<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p>
1286</td>
1287</tr>
1288</tbody>
1289</table>
1290<p>Permits you to set the value of an input form or textarea. You must
1291supply the field name via the first parameter of the function. The
1292second (optional) parameter allows you to set a default value for the
1293form. The third (optional) parameter allows you to turn off HTML escaping
1294of the value, in case you need to use this function in combination with
1295i.e. <a class="reference internal" href="#form_input" title="form_input"><code class="xref php php-func docutils literal"><span class="pre">form_input()</span></code></a> and avoid double-escaping.</p>
1296<p>Example:</p>
1297<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="o">&lt;</span><span class="nx">input</span> <span class="nx">type</span><span class="o">=</span><span class="s2">&quot;text&quot;</span> <span class="nx">name</span><span class="o">=</span><span class="s2">&quot;quantity&quot;</span> <span class="nx">value</span><span class="o">=</span><span class="s2">&quot;&lt;?php echo set_value(&#39;quantity&#39;, &#39;0&#39;); ?&gt;&quot;</span> <span class="nx">size</span><span class="o">=</span><span class="s2">&quot;50&quot;</span> <span class="o">/&gt;</span>
1298</pre></div>
1299</div>
1300<p>The above form will show “0” when loaded for the first time.</p>
1301<div class="admonition note">
1302<p class="first admonition-title">Note</p>
1303<p class="last">If you’ve loaded the <a class="reference internal" href="../libraries/form_validation.html"><span class="doc">Form Validation Library</span></a> and
1304have set a validation rule for the field name in use with this helper, then it will
1305forward the call to the <a class="reference internal" href="../libraries/form_validation.html"><span class="doc">Form Validation Library</span></a>’s
1306own <code class="docutils literal"><span class="pre">set_value()</span></code> method. Otherwise, this function looks in <code class="docutils literal"><span class="pre">$_POST</span></code> for the
1307field value.</p>
1308</div>
1309</dd></dl>
1310
1311<dl class="function">
1312<dt id="set_select">
1313<code class="descname">set_select</code><span class="sig-paren">(</span><em>$field</em><span class="optional">[</span>, <em>$value = ''</em><span class="optional">[</span>, <em>$default = FALSE</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#set_select" title="Permalink to this definition"></a></dt>
1314<dd><table class="docutils field-list" frame="void" rules="none">
1315<col class="field-name" />
1316<col class="field-body" />
1317<tbody valign="top">
1318<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
1319<li><strong>$field</strong> (<em>string</em>) – Field name</li>
1320<li><strong>$value</strong> (<em>string</em>) – Value to check for</li>
1321<li><strong>$default</strong> (<em>string</em>) – Whether the value is also a default one</li>
1322</ul>
1323</td>
1324</tr>
1325<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">‘selected’ attribute or an empty string</p>
1326</td>
1327</tr>
1328<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p>
1329</td>
1330</tr>
1331</tbody>
1332</table>
1333<p>If you use a &lt;select&gt; menu, this function permits you to display the
1334menu item that was selected.</p>
1335<p>The first parameter must contain the name of the select menu, the second
1336parameter must contain the value of each item, and the third (optional)
1337parameter lets you set an item as the default (use boolean TRUE/FALSE).</p>
1338<p>Example:</p>
1339<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="o">&lt;</span><span class="nx">select</span> <span class="nx">name</span><span class="o">=</span><span class="s2">&quot;myselect&quot;</span><span class="o">&gt;</span>
1340 <span class="o">&lt;</span><span class="nx">option</span> <span class="nx">value</span><span class="o">=</span><span class="s2">&quot;one&quot;</span> <span class="o">&lt;?</span><span class="nx">php</span> <span class="k">echo</span> <span class="nx">set_select</span><span class="p">(</span><span class="s1">&#39;myselect&#39;</span><span class="p">,</span> <span class="s1">&#39;one&#39;</span><span class="p">,</span> <span class="k">TRUE</span><span class="p">);</span> <span class="cp">?&gt;</span> &gt;One<span class="p">&lt;/</span><span class="nt">option</span><span class="p">&gt;</span>
1341 <span class="p">&lt;</span><span class="nt">option</span> <span class="na">value</span><span class="o">=</span><span class="s">&quot;two&quot;</span> <span class="cp">&lt;?php</span> <span class="k">echo</span> <span class="nx">set_select</span><span class="p">(</span><span class="s1">&#39;myselect&#39;</span><span class="p">,</span> <span class="s1">&#39;two&#39;</span><span class="p">);</span> <span class="cp">?&gt;</span> <span class="p">&gt;</span>Two<span class="p">&lt;/</span><span class="nt">option</span><span class="p">&gt;</span>
1342 <span class="p">&lt;</span><span class="nt">option</span> <span class="na">value</span><span class="o">=</span><span class="s">&quot;three&quot;</span> <span class="cp">&lt;?php</span> <span class="k">echo</span> <span class="nx">set_select</span><span class="p">(</span><span class="s1">&#39;myselect&#39;</span><span class="p">,</span> <span class="s1">&#39;three&#39;</span><span class="p">);</span> <span class="cp">?&gt;</span> <span class="p">&gt;</span>Three<span class="p">&lt;/</span><span class="nt">option</span><span class="p">&gt;</span>
1343<span class="p">&lt;/</span><span class="nt">select</span><span class="p">&gt;</span>
1344</pre></div>
1345</div>
1346</dd></dl>
1347
1348<dl class="function">
1349<dt id="set_checkbox">
1350<code class="descname">set_checkbox</code><span class="sig-paren">(</span><em>$field</em><span class="optional">[</span>, <em>$value = ''</em><span class="optional">[</span>, <em>$default = FALSE</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#set_checkbox" title="Permalink to this definition"></a></dt>
1351<dd><table class="docutils field-list" frame="void" rules="none">
1352<col class="field-name" />
1353<col class="field-body" />
1354<tbody valign="top">
1355<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
1356<li><strong>$field</strong> (<em>string</em>) – Field name</li>
1357<li><strong>$value</strong> (<em>string</em>) – Value to check for</li>
1358<li><strong>$default</strong> (<em>string</em>) – Whether the value is also a default one</li>
1359</ul>
1360</td>
1361</tr>
1362<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">‘checked’ attribute or an empty string</p>
1363</td>
1364</tr>
1365<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p>
1366</td>
1367</tr>
1368</tbody>
1369</table>
1370<p>Permits you to display a checkbox in the state it was submitted.</p>
1371<p>The first parameter must contain the name of the checkbox, the second
1372parameter must contain its value, and the third (optional) parameter
1373lets you set an item as the default (use boolean TRUE/FALSE).</p>
1374<p>Example:</p>
1375<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="o">&lt;</span><span class="nx">input</span> <span class="nx">type</span><span class="o">=</span><span class="s2">&quot;checkbox&quot;</span> <span class="nx">name</span><span class="o">=</span><span class="s2">&quot;mycheck&quot;</span> <span class="nx">value</span><span class="o">=</span><span class="s2">&quot;1&quot;</span> <span class="o">&lt;?</span><span class="nx">php</span> <span class="k">echo</span> <span class="nx">set_checkbox</span><span class="p">(</span><span class="s1">&#39;mycheck&#39;</span><span class="p">,</span> <span class="s1">&#39;1&#39;</span><span class="p">);</span> <span class="cp">?&gt;</span> /&gt;
1376<span class="p">&lt;</span><span class="nt">input</span> <span class="na">type</span><span class="o">=</span><span class="s">&quot;checkbox&quot;</span> <span class="na">name</span><span class="o">=</span><span class="s">&quot;mycheck&quot;</span> <span class="na">value</span><span class="o">=</span><span class="s">&quot;2&quot;</span> <span class="cp">&lt;?php</span> <span class="k">echo</span> <span class="nx">set_checkbox</span><span class="p">(</span><span class="s1">&#39;mycheck&#39;</span><span class="p">,</span> <span class="s1">&#39;2&#39;</span><span class="p">);</span> <span class="cp">?&gt;</span> <span class="p">/&gt;</span>
1377</pre></div>
1378</div>
1379</dd></dl>
1380
1381<dl class="function">
1382<dt id="set_radio">
1383<code class="descname">set_radio</code><span class="sig-paren">(</span><em>$field</em><span class="optional">[</span>, <em>$value = ''</em><span class="optional">[</span>, <em>$default = FALSE</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#set_radio" title="Permalink to this definition"></a></dt>
1384<dd><table class="docutils field-list" frame="void" rules="none">
1385<col class="field-name" />
1386<col class="field-body" />
1387<tbody valign="top">
1388<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
1389<li><strong>$field</strong> (<em>string</em>) – Field name</li>
1390<li><strong>$value</strong> (<em>string</em>) – Value to check for</li>
1391<li><strong>$default</strong> (<em>string</em>) – Whether the value is also a default one</li>
1392</ul>
1393</td>
1394</tr>
1395<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">‘checked’ attribute or an empty string</p>
1396</td>
1397</tr>
1398<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p>
1399</td>
1400</tr>
1401</tbody>
1402</table>
1403<p>Permits you to display radio buttons in the state they were submitted.
1404This function is identical to the <a class="reference internal" href="#set_checkbox" title="set_checkbox"><code class="xref php php-func docutils literal"><span class="pre">set_checkbox()</span></code></a> function above.</p>
1405<p>Example:</p>
1406<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="o">&lt;</span><span class="nx">input</span> <span class="nx">type</span><span class="o">=</span><span class="s2">&quot;radio&quot;</span> <span class="nx">name</span><span class="o">=</span><span class="s2">&quot;myradio&quot;</span> <span class="nx">value</span><span class="o">=</span><span class="s2">&quot;1&quot;</span> <span class="o">&lt;?</span><span class="nx">php</span> <span class="k">echo</span> <span class="nx">set_radio</span><span class="p">(</span><span class="s1">&#39;myradio&#39;</span><span class="p">,</span> <span class="s1">&#39;1&#39;</span><span class="p">,</span> <span class="k">TRUE</span><span class="p">);</span> <span class="cp">?&gt;</span> /&gt;
1407<span class="p">&lt;</span><span class="nt">input</span> <span class="na">type</span><span class="o">=</span><span class="s">&quot;radio&quot;</span> <span class="na">name</span><span class="o">=</span><span class="s">&quot;myradio&quot;</span> <span class="na">value</span><span class="o">=</span><span class="s">&quot;2&quot;</span> <span class="cp">&lt;?php</span> <span class="k">echo</span> <span class="nx">set_radio</span><span class="p">(</span><span class="s1">&#39;myradio&#39;</span><span class="p">,</span> <span class="s1">&#39;2&#39;</span><span class="p">);</span> <span class="cp">?&gt;</span> <span class="p">/&gt;</span>
1408</pre></div>
1409</div>
1410<div class="admonition note">
1411<p class="first admonition-title">Note</p>
1412<p class="last">If you are using the Form Validation class, you must always specify
1413a rule for your field, even if empty, in order for the <code class="docutils literal"><span class="pre">set_*()</span></code>
1414functions to work. This is because if a Form Validation object is
1415defined, the control for <code class="docutils literal"><span class="pre">set_*()</span></code> is handed over to a method of the
1416class instead of the generic helper function.</p>
1417</div>
1418</dd></dl>
1419
1420<dl class="function">
1421<dt id="form_error">
1422<code class="descname">form_error</code><span class="sig-paren">(</span><span class="optional">[</span><em>$field = ''</em><span class="optional">[</span>, <em>$prefix = ''</em><span class="optional">[</span>, <em>$suffix = ''</em><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#form_error" title="Permalink to this definition"></a></dt>
1423<dd><table class="docutils field-list" frame="void" rules="none">
1424<col class="field-name" />
1425<col class="field-body" />
1426<tbody valign="top">
1427<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
1428<li><strong>$field</strong> (<em>string</em>) – Field name</li>
1429<li><strong>$prefix</strong> (<em>string</em>) – Error opening tag</li>
1430<li><strong>$suffix</strong> (<em>string</em>) – Error closing tag</li>
1431</ul>
1432</td>
1433</tr>
1434<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">HTML-formatted form validation error message(s)</p>
1435</td>
1436</tr>
1437<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p>
1438</td>
1439</tr>
1440</tbody>
1441</table>
1442<p>Returns a validation error message from the <a class="reference internal" href="../libraries/form_validation.html"><span class="doc">Form Validation Library</span></a>, associated with the specified field name.
1443You can optionally specify opening and closing tag(s) to put around the error
1444message.</p>
1445<p>Example:</p>
1446<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="c1">// Assuming that the &#39;username&#39; field value was incorrect:</span>
1447<span class="k">echo</span> <span class="nx">form_error</span><span class="p">(</span><span class="s1">&#39;myfield&#39;</span><span class="p">,</span> <span class="s1">&#39;&lt;div class=&quot;error&quot;&gt;&#39;</span><span class="p">,</span> <span class="s1">&#39;&lt;/div&gt;&#39;</span><span class="p">);</span>
1448
1449<span class="c1">// Would produce: &lt;div class=&quot;error&quot;&gt;Error message associated with the &quot;username&quot; field.&lt;/div&gt;</span>
1450</pre></div>
1451</div>
1452</dd></dl>
1453
1454<dl class="function">
1455<dt id="validation_errors">
1456<code class="descname">validation_errors</code><span class="sig-paren">(</span><span class="optional">[</span><em>$prefix = ''</em><span class="optional">[</span>, <em>$suffix = ''</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#validation_errors" title="Permalink to this definition"></a></dt>
1457<dd><table class="docutils field-list" frame="void" rules="none">
1458<col class="field-name" />
1459<col class="field-body" />
1460<tbody valign="top">
1461<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
1462<li><strong>$prefix</strong> (<em>string</em>) – Error opening tag</li>
1463<li><strong>$suffix</strong> (<em>string</em>) – Error closing tag</li>
1464</ul>
1465</td>
1466</tr>
1467<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">HTML-formatted form validation error message(s)</p>
1468</td>
1469</tr>
1470<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p>
1471</td>
1472</tr>
1473</tbody>
1474</table>
1475<p>Similarly to the <a class="reference internal" href="#form_error" title="form_error"><code class="xref php php-func docutils literal"><span class="pre">form_error()</span></code></a> function, returns all validation
1476error messages produced by the <a class="reference internal" href="../libraries/form_validation.html"><span class="doc">Form Validation Library</span></a>, with optional opening and closing tags
1477around each of the messages.</p>
1478<p>Example:</p>
1479<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="k">echo</span> <span class="nx">validation_errors</span><span class="p">(</span><span class="s1">&#39;&lt;span class=&quot;error&quot;&gt;&#39;</span><span class="p">,</span> <span class="s1">&#39;&lt;/span&gt;&#39;</span><span class="p">);</span>
1480
1481<span class="cm">/*</span>
1482<span class="cm"> Would produce, e.g.:</span>
1483
1484<span class="cm"> &lt;span class=&quot;error&quot;&gt;The &quot;email&quot; field doesn&#39;t contain a valid e-mail address!&lt;/span&gt;</span>
1485<span class="cm"> &lt;span class=&quot;error&quot;&gt;The &quot;password&quot; field doesn&#39;t match the &quot;repeat_password&quot; field!&lt;/span&gt;</span>
1486
1487<span class="cm"> */</span>
1488</pre></div>
1489</div>
1490</dd></dl>
1491
1492<dl class="function">
1493<dt id="form_prep">
1494<code class="descname">form_prep</code><span class="sig-paren">(</span><em>$str</em><span class="sig-paren">)</span><a class="headerlink" href="#form_prep" title="Permalink to this definition"></a></dt>
1495<dd><table class="docutils field-list" frame="void" rules="none">
1496<col class="field-name" />
1497<col class="field-body" />
1498<tbody valign="top">
1499<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
1500<li><strong>$str</strong> (<em>string</em>) – Value to escape</li>
1501</ul>
1502</td>
1503</tr>
1504<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Escaped value</p>
1505</td>
1506</tr>
1507<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">string</p>
1508</td>
1509</tr>
1510</tbody>
1511</table>
1512<p>Allows you to safely use HTML and characters such as quotes within form
1513elements without breaking out of the form.</p>
1514<div class="admonition note">
1515<p class="first admonition-title">Note</p>
1516<p class="last">If you use any of the form helper functions listed in this page the form
1517values will be prepped automatically, so there is no need to call this
1518function. Use it only if you are creating your own form elements.</p>
1519</div>
1520<div class="admonition note">
1521<p class="first admonition-title">Note</p>
1522<p class="last">This function is DEPRECATED and is just an alias for
1523<a class="reference internal" href="../general/common_functions.html"><span class="doc">common function</span></a>
1524<code class="xref py py-func docutils literal"><span class="pre">html_escape()</span></code> - please use that instead.</p>
1525</div>
1526</dd></dl>
1527
1528</div>
1529</div>
1530
1531
1532 </div>
1533 <footer>
1534
1535 <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
1536
1537 <a href="html_helper.html" class="btn btn-neutral float-right" title="HTML Helper">Next <span class="fa fa-arrow-circle-right"></span></a>
1538
1539
1540 <a href="file_helper.html" class="btn btn-neutral" title="File Helper"><span class="fa fa-arrow-circle-left"></span> Previous</a>
1541
1542 </div>
1543
1544
1545 <hr/>
1546
1547 <div role="contentinfo">
1548 <p>
1549 &copy; Copyright 2014 - 2019, British Columbia Institute of Technology.
1550 Last updated on Jan 16, 2019.
1551 </p>
1552 </div>
1553
1554 Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
1555
1556</footer>
1557 </div>
1558 </div>
1559
1560 </section>
1561
1562 </div>
1563
1564
1565
1566
1567
1568 <script type="text/javascript">
1569 var DOCUMENTATION_OPTIONS = {
1570 URL_ROOT:'../',
1571 VERSION:'3.1.10',
1572 COLLAPSE_INDEX:false,
1573 FILE_SUFFIX:'.html',
1574 HAS_SOURCE: false
1575 };
1576 </script>
1577 <script type="text/javascript" src="../_static/jquery.js"></script>
1578 <script type="text/javascript" src="../_static/underscore.js"></script>
1579 <script type="text/javascript" src="../_static/doctools.js"></script>
1580
1581
1582
1583
1584
1585 <script type="text/javascript" src="../_static/js/theme.js"></script>
1586
1587
1588
1589
1590 <script type="text/javascript">
1591 jQuery(function () {
1592 SphinxRtdTheme.StickyNav.enable();
1593 });
1594 </script>
1595
1596
1597</body>
1598</html>