Contents
FormCreate
Description
Generates arbitrary forms. Submited data can be processed in two different ways:
- by any action that is able to process submited data (single action execution only)
by FormSubmit action plugin which can be found in ActionMarket (supports execution of multiple actions)
Note: FormCreate macro should be used together with FormSubmit action plugin.
The following HTML elements are currently supported:
- Text field
- Textarea
- Upload field
- Select box
- Check box
- Radio button
- Submit button
Download & Release Notes
Download |
Release Version |
Moin Version |
Release Notes |
|
1.7, 1.8 |
|
|
|
1.6 |
|
Usage
Entire form is generated by sequential execution of multiple form macro plugins. Field generation macros have to be enclosed between FormHeader and FormFooter macro. First parameter of FormHeader macro is action or list of actions to be executed after submiting a form.
FormHeader
Single action:
<<FormHeader(action[,targetfile=][,targetpage=][,targetemail=])>>
Arbitrary action can be executed this way.
Multiple actions:
<<FormHeader(action1, action2, actionN[,targetfile=][,targetpage=][,targetemail=])>>
This option can only be used with FormSubmit action plugin.
Currently supported actions by FormSubmit:
submitattachment - attach file to wikipage defined in targetpage parameter
submitcsv - append line into csv file defined in targetfile parameter and append it to targetpage attachment directory
submitemail - send an email to address defined in targetemail parameter
Parameters
action - action to process submited data
targetfile= - csv file name
targetpage= - target wiki page for attachments and csv file
targetemail= - target email for submited data
FormField
First parameter of each field except FormSubmit is label. Labels are used as header informations in csv files or emails and also as name attribute in HTML tag. Dictionary parameters are used to generate specific HTML attributes. Not all attributes are supported. Next parameters differs in each type of field.
Example
<<FormHeader(submitattachment, submitcsv, submitemail, targetfile=file.csv, targetpage=Page_for_csv_and_attachments, targetemail=email@address.net)>> || First name: || <<FormText(First name,maxlength=50)>> || || Last name: || <<FormText(Last name,maxlength=50)>> || || Gender: || Male<<FormRadio(Gender, Male)>> Female<<FormRadio(Gender, Female)>> || || Status: || <<FormSelect(Status, Single, Married, Divorced)>> || || Children: || <<FormCheckbox(Children, Yes, No)>> || || Note: || <<FormTextarea(Note, rows=10, cols=20)>> || || Attachment: || <<FormUpload(Attachment)>> || ||<-2:> <<FormSubmit(Send)>> || <<FormFooter()>>
Example shown above generates the following form:
After submission of this form, the following actions are performed:
specified attachment is uploaded into 'Page_for_csv_and_attachments' page
form data are appended into 'Page_for_csv_and_attachments/attachments/file.csv' file
form data are sent to 'email@address.net'
Copyright
2008 by Peter Bodi
License
GNU GPL
Bugs
Open
Immutable Error in Moin 1.9.3 and Python 2.6.6
I have installed both the FormCreate macro and FormSubmit actions and have been unable to get them working. I am using the example form from this page. I have tracked down the problem to be in the submitbase.py action, but I am not a python programmer and heavy searching has not lead me to a possible solution. Any help would be appreciated! Also, I have tried to get more specific tracebacks (like multiple attachment problem bug), but couldn't find any info - so this as concise as I can make it:
Traceback (most recent call last):
File "C:/Wiki/Lib/site-packages\MoinMoin\wsgiapp.py", line 282, in __call__
response = run(context)
File "C:/Wiki/Lib/site-packages\MoinMoin\wsgiapp.py", line 88, in run
response = dispatch(request, context, action_name)
File "C:/Wiki/Lib/site-packages\MoinMoin\wsgiapp.py", line 136, in dispatch
response = handle_action(context, pagename, action_name)
File "C:/Wiki/Lib/site-packages\MoinMoin\wsgiapp.py", line 195, in handle_action
handler(context.page.page_name, context)
File "C:\Wiki\wikidata\share\moin\data\plugin\action\submitemail.py", line 22, in execute
submitemail(pagename, request).render()
File "C:\Wiki\wikidata\share\moin\data\plugin\action\submitemail.py", line 27, in __init__
SubmitBase.__init__(self, pagename, request)
File "C:\Wiki\wikidata\share\moin\data\plugin\action\submitbase.py", line 72, in __init__
self.fields = self._exclude_metadata(self.request.form)
File "C:\Wiki\wikidata\share\moin\data\plugin\action\submitbase.py", line 208, in _exclude_metadata
fields = copy.deepcopy(form)
File "C:\Program Files\Wiki Software\Python26\Lib\copy.py", line 189, in deepcopy
y = _reconstruct(x, rv, 1, memo)
File "C:\Program Files\Wiki Software\Python26\Lib\copy.py", line 335, in _reconstruct
y[key] = value
File "C:\Wiki\Lib\site-packages\MoinMoin\support\werkzeug\datastructures.py", line 100, in __setitem__
is_immutable(self)
File "C:\Wiki\Lib\site-packages\MoinMoin\support\werkzeug\datastructures.py", line 21, in is_immutable
raise TypeError('%r objects are immutable' % self.__class__.__name__)
TypeError: 'ImmutableMultiDict' objects are immutableMoin 1.9.3 / Python 2.6.6 / Apache 2.2.19 (for python 2.6.6) / Win32
--Galaxie500 2011-10-31
Adding an Attachment should be optional
If you create a form with the possibility to upload a file and the user did not specific any file you will receive an message "File was not specified". But the form will be sended via e-mail anyway. and the user only recive this error message. so he thinks that the mail was not proccess and will try again
- in my case adding an attachment is optional, so the current case is not as bad, but the current "workflow" of the messages is not good.
More than one Attachment is not working
MoinMoin Version: 1.8.5
It seems that with the <<FormUpload(bandphoto)>> macro is not possible to upload more then one attachment, right? Error Message is "KeyError", see here traceback-keyerror.html
btw. this is awesome plug-in, thanks for the great work! -- MarcelHäfner 2009-09-22 12:21:24
Fixed
Upload of attachment is not working
MoinMoin Version: 1.8.5
I tried now with a single attachment, but it seems not to save the attachment. If I use a big file to upload, it takes a while, thats why I think the formular part is working and only the action "submitattachment.py" has some troubles. saveing stuff as csv is working well.
Update: Everything is working, you just need to add "submitattachment" even if you only want e-mail senders. -- MarcelHäfner 2009-09-23 07:33:00
Others
Copied the files into mywikiinstance/plugin/macro and then pasted the example code above in a new page, got the error:
/mywikiinstance/plugin/macro/FormHeader.py in () 10 11 from MoinMoin.Page import Page 12 from wikiconfig.plugin.macro.FormBase import FormBase 13 14 class FormHeader(FormBase): wikiconfig undefined , FormBase undefined
Solution: Remove wikiconfig.plugin.macro. from all imports. At least this worked for me with MoinMoin 1.8.0beta1. -- JoachimWagner 2008-10-07 16:30:08
I also fixed a few other bugs in the code and it is now working for me on MoinMoin 1.8.0rc1. Here is the fixed version. I still cannot find the solution for two bugs (maybe MoinMoin bugs): First is related to the message displayed when the form is sent. Sometimes the message on the top of the screen appears correctly. When the form is submitted again I get this error:
/mywikiinstance/plugin/action/submitbase.py in render_success (self=<wikiconfig.p_174f1ff880d7230de680da859ea65048a9...action.submitcsv.submitcsv instance at 0x1521d40>, msg='Data has been processed successfuly') 177 """ Triggered on success """ 178 self._delete_cache() 179 ActionBase.render_success(self, msg, 'info') 180 181 def render_msg(self, msg): global ActionBase = <class MoinMoin.action.ActionBase at 0xcf3770> ActionBase.render_success = <unbound method ActionBase.render_success> self = <wikiconfig.p_174f1ff880d7230de680da859ea65048a9...action.submitcsv.submitcsv instance at 0x1521d40> msg = 'Data has been processed successfuly'
The other error is that sometimes the source of the form is rendered into the page. Maybe these errors are related to the caching mechanism of MoinMoin. (I am a newbie, sorry for naive ideas and questions) -- GurkPeter 2008-10-08 17:21:08
HELP! I've installed both plugin but I get the following error when clicking "send"
Cannot import name mail
Why does this error appear? I'm running MoinVersion 1.6.4 an Python 2.5
-- PeterPan 2008-12-12 13:31:49
Discussion
Some Ideas or feature requests (-- MarcelHäfner 2009-09-23 16:48:01):
Necessary fields
first I would like to add some parameter for "requirement" fields. without filling out or clicked this fields/buttons it should be not possible to send the form. sure the user should receive a visual feedback, about missing fieldsDefault value
A default value for some check-box or drop-down would also be very nice.Log
It would nice if the form (csv or mail) could log the ip and if he's logged in also his usernameIs the Macro/Action running (partly) in moin 1.9.3 ? -- DuffDave
