version=pmwiki-2.2.5 ordered=1 urlencoded=1 agent=Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.0.12) Gecko/2009070811 Ubuntu/9.04 (jaunty) Firefox/3.0.12 author=Petko charset=ISO-8859-1 csum= ctime=1181479161 host=81.65.12.233 name=PmWiki.Forms rev=44 targets=Cookbook.Input text=(:Summary:How you can embed input forms into wiki pages:)%0aThis page explains how you can embed input forms into wiki pages.%0a%0aInput forms don't actually handle processing of the form data -- the feature simply allows creation of forms inside wiki pages. Forms processing can be found in the Cookbook (see below).%0a%0a!! Markup%0aTwo directives are used to begin and end forms:%0a%0a [=(:input=] form "''url''" ''method'':)%0a ...%0a [=(:input end:)=]%0a%0aThe [@(:input form:)@] directive starts a form that will post to ''url'' using the supplied ''method''. The ''url'' must be in quotes. If the url is omitted, then the current page is assumed. If ''method'' is omitted then "POST" is assumed. The [@(:input end:)@] directive ends the current form.%0a%0aNote that this feature doesn't ensure that the form output is correct HTML -- it assumes the author knows a little bit of what he or she is doing. Notably, [=(:input form:) and (:input end:)=] shouldn't appear inside tables, and all form fields and controls should be inside an [=(:input form:)...(:input end:)=] block.%0a%0a[[#standardinputcontrols]]%0a!!!Standard input controls%0aThe standard input controls are:%0a%0a [=(:input=] text ''name'' ''value'' size=''n'':)%0a [=(:input=] hidden ''name'' ''value'':)%0a [=(:input=] password ''name'' ''value'':)%0a [=(:input=] radio ''name'' ''value'':)%0a [=(:input=] checkbox ''name'' ''value'':)%0a [=(:input=] [[#select|select]] ''name'' ''value'' ''label'':)%0a [=(:input=] [[Cookbook:InputDefault|default]] ''default-name'' ''default-value'':) %0a [=(:input=] submit ''name'' ''value'':)%0a [=(:input=] textarea ''name'' ''[@[=value=]@]'' rows=''n'' cols=''n'':)%0a [=(:input=] reset ''name'' ''label'':)%0a [=(:input=] file ''name'' ''label'':)%0a [=(:input=] image ''name'' ''"src"'' ''alt'':)%0a%0aWhere ''name'' and ''value'' are in the HTML syntax: name="addr" value="808 W Franklin".%0a%0aFor most controls the markup has the form:%0a%0a [=(:input=] ''type'' ''name'' ''value'' ''parameter=value'':)%0a%0awhere ''type'' is the type of input element (described below), ''name'' is the name of the control, ''value'' is its initial value, and parameters are used to specify additional attributes to the control. If ''value'' contains spaces, enclose it in quotes; if it contains newlines (for textarea and hidden elements), enclose it in [@[=...=]@]. %0a%0aFor example, the following creates a text input control with a size of 30 characters:%0a%0a(:markup:)%0a(:input text authorid "Jane Doe" size=30:)%0a(:markupend:)%0a%0aFor convenience, an author can also specify name and value arguments directly using [@name=@] and [@value=@] attributes (same as HTML):%0a%0a(:markup:) %0a(:input text name=authorid value="Jane Doe" size=30:)%0a(:markupend:)%0a%0aFor the @@textarea@@ control a value can be set from PmWiki 2.2.0beta45 onwards. Enclose the value in [@[=...=]@] if it contains spaces or new lines.%0a%0aThe [@submit@] control will more often be written as:%0a%0a [=(:input=] submit value=''label'':)%0a%0aHere's a more complete example, e.g., for a login prompt:%0a%0a(:markup:) [=%0a(:input form "http://www.example.com":)%0a(:input hidden action login:)%0a|| Name:||(:input text username:) ||%0a|| Password:||(:input password password:)||%0a|| ||(:input submit value="Log In":) ||%0a(:input end:)%0a=]%0a%0a%0a[[#select]]%0a!![@(:input select ... :)@]%0a%0aThe basic form of a select box is a sequence of options:%0a%0a(:markup:) [=%0a(:input form:)%0a(:input select name=abc value=1 label=alpha :)%0a(:input select name=abc value=2 label=beta :)%0a(:input select name=abc value=3 label=gamma :)%0a(:input submit:)%0a(:input end:)%0a=]%0a%0aThe values can be specified positionally:%0a [=(:input select abc 1 alpha :)=]%0a%0aWe can specify the size of the selection box:%0a [=(:input select abc 1 alpha size=3 :)=]%0a%0aYou can specify a multiple select box:%0a [=(:input select abc 1 alpha size=3 multiple:)=]%0a%0aTo have an element selected, use @@selected=selected@@:%0a [=(:input select abc 2 beta selected=selected:)=]%0a%0aNote that to have two select boxes inline, not only should you give them different @@name=@@ parameters, but also place a separator, like a character, [@ @] or even the null sequence [@[==]@] between them:%0a(:markup:)%0a(:input form:)%0a(:input select name=FIRST value=1:)(:input select name=FIRST value=2:)[==]%0a(:input select name=SECOND value=3:)(:input select name=SECOND value=4:)%0a(:input end:)%0a(:markupend:)%0a%0a!! See Also%0a*[[Cookbook:Input Default]] {Cookbook.InputDefault$:Summary}%0a*[[Cookbook:Form Validation]] {Cookbook.FormValidation$:Summary}%0a*[[Cookbook:Form Extensions]] {Cookbook.FormExtensions$:Summary}%0a*[[Cookbook:Input Forms and JavaScript]] {Cookbook.InputFormsAndJavaScript$:Summary}%0a%0aCompatible recipes:%0a* [[Cookbook:PmForm]] {Cookbook/PmForm$:Summary}%0a* [[Cookbook:Fox]] {Cookbook.Fox$:Summary}%0a* [[Cookbook:Wiki Forms]] {Cookbook/WikiForms$:Summary}%0a* [[Cookbook:ProcessForm]] {Cookbook/ProcessForm$:Summary}%0a%0a time=1251330173