|
Cookbook /
BuildFormsSummary: Create an HTML form with Wiki markup, save values in a file, and pass values to a user defined function
Version: 0.8 (16 May 2005)
Prerequisites: Last tested on PmWiki version: 2.0.beta26; requires at least PmWiki version: 2.0.beta24 (the
ParseArgs internal function is used)Status:
Maintainer:
<< | Forms-related | Enable HTML >> GoalCreate an HTML form with Wiki markup, save values in a file, and pass values to a user defined function. (see CompareFormsRecipes) SolutionsInstall the buildforms addon
This is a preliminary version - Please report any problem in the discussion paragraph below or by mail. Installation:
Notes and comments
Usage
form opening with form closing (imperative) by All markup names should be different, if not the last overwrite the other. Elements :
To have a multiple line select box, set parameter size=n n being the line number Displayed text is equal to the markup name, but you can change that with the parameter disp="display anything" frmfield display the disp text after the input box. If you want to display the input box on the right of the text, you should use 'pos=right' parameter, and you will probably have to set the field in a table to align it properly:
default values are set with value=anyvalue or value="another value" For radio and select box, set as value the chosen option name to set this option as default. To have a checkbox checked by default, set value=nameofchk e.g. : (:frmcheck chk_x value=chk_x disp="option to be selected":) regex='regex expression' control and capture your input. If not valid, the value is left unmodified New in rev0.7: user function name should start by 'frmuf' ('form user function', use lower case) to improve safety. While all buttons submit the form, there are buttons with special behaviour:
Complementary parameters can be defined by setting their name in the init (no blanks, comma separated)
and then you will set in each markup a fixed value.
Hidden field (to be stored or sent to a cgi)
Some markup examples : (:frminit params=csstype,area:) (:frmbutton ok disp=" Ok " function=skincsscre:)[[<<]] (:frmmsg msgresult:)[[<<]] (:frmfield sztext value=100% disp="Text - def:100%" regex="[1-9][0-9][0-9]?%" size=4 csstype=font-size area=body:)[[<<]] (:frmfield sidemrgl value=8px size=3 regex="[0-9][0-9]?px" disp="Left - def:8px" csstype=padding-left area=#wikileft:) (:frmend:) Please note that instead what is shown above for better presentation, each markup shall be on one line only. These parameters will be stored in the file $pagename.prm, and then set in a global value to be used by your client function. name1:value1 name2:value_x name3:value_z name3:multilines text`2nd line and`third line So, to send back a message to your page, you have only to append to the
See the new skinnice module as an exemple of use : Have a look to the site example for detailed use. More infos to come. Site example : read password is 'miaou' . Application example read password is 'miaou' . The format of the name1:value="value x" function="myfunc" perspar1="constant1x" perspar2="constant2x" name2:value="value 2" regex="expr." perspar1="constant1y" perspar2="constant2y" name3:value="value 3" size="nn" perspar1="" perspar2="" To send the parameters to an external cgi, set the parameter 'action=' in the frminit directive as in:
Parameters are stored locally before being sent to the cgi. Only an 'ok' button send the values to the cgi, so you can have a 'save' button to store locally before sending to the cgi. As for now, parameters are not get from the CGI. If someone needs it, please inform and supply a valid address with a working CGI able to return parameters. Reading parametersYou can read parameters from another page with the Defining a default page where the parameters should be read is done with
and then the parameters are read from this page:
This simply display brute parameter, but you can improve the display with the 'disp' flag, which have different behaviour following the kind of input (field, checkboxe, radiobutton, etc.) and use the content of the 'disp=' parameter in the data source page
If you want to read only one parameter from a specific page, you can do with an optional 'page=' parameter:
Restrictions
ConfigurationOn PmWiki2 only. TranslationsLicenseGPL History
ContributorDiscussion
I have been working with this script, and it seems to work nicely offline. But I when I uploaded to my server, I got these php errors:
Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/fastst/public_html/fastwiki/system/cookbook/buildforms.php on line 314 Warning: fsockopen(): unable to connect to :80 in /home/fastst/public_html/fastwiki/system/cookbook/buildforms.php on line 314 Warning: Cannot modify header information - headers already sent by (output started at /home/fastst/public_html/fastwiki/system/cookbook/buildforms.php:314) in /home/fastst/public_html/fastwiki/system/pmwiki.php on line 796 Warning: Cannot modify header information - headers already sent by (output started at /home/fastst/public_html/fastwiki/system/cookbook/buildforms.php:314) in /home/fastst/public_html/fastwiki/system/pmwiki.php on line 797 It then proceeds to process the script. Any suggestions? Caveman
User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki. |