form_helper.html 114 KB

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