Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
mem_simple_form
Edit: 2010-10-03
Please go to http://bitbucket.org/Manfre/txp-plugins if you…- are having a problem and want to report a bug
- would like to request a new feature
- are looking for documentation
- are looking for the plugin code
- are looking to download the latest ready to install plugin file
I do not regularly follow this thread anymore. Any problems or questions posted here will most likely only get answered by other forum members.
Original post
In an effort to empower more Textpattern users, I have created the plugin mem_simple_form. This plugin will allow a site owner to create a form that is able to accept an arbitrary number of fields and store them in to an existing database table. Basic processing can be done to the fields after the form is submitted.
mem_simple_form version 0.3
This tag will output an HTML form. The HTML form field names must follow the pattern “type_name”, where type is a value from the below type list. The database table’s field name must match name exactly.
Form Types:
- now – MySQL “NOW” function. Use with mem_form_secret or mem_form_hidden.
- password – MySQL “PASSWORD” function
- oldpassword – MySQL “OLD_PASSWORD()” function
- md5 – MySQL “MD5” function
- sha1 – MySQL “SHA1” function
- rand – MySQL “RAND” function. Use with mem_form_secret or mem_form_hidden.
- textile – Textile parse field
- nl2br – Convert newlines to br tags
- randuid – Generate a random unique id (md5 hash). Use with mem_form_secret or mem_form_hidden.
- lower – Convert to lower case
- upper – Convert to upper case
- string – No processing
- int – Field contains a numeric value
- table string Name of the table to insert data on a successful form submission.
- id_field string If specified, this is the name of the table field that is a PRIMARY KEY or UNIQUE INDEX. This allows updates if a record with a matching ID already exists.
- id_insert int If “1”, the ID field will be inserted/updated. Otherwise, the field is assumed to be auto generated by the database.
- ignore_fields string A comma separated string of field names (including prefixes) that will not be written to the table. These are handy for ToS checkboxes and CAPTCHAs.
- form string Name of form that contains the mem_simple_form form tags.
- success_form string Name of the form that will be shown after a successful post.
mem_simple_if_ps
Conditional tag that checks to see if a HTML field was posted, or if it has a specific value.
- name string HTML field name posted with the form.
- equal string Value to compare against the value of name. If not specified, tag checks to see if form posted variable HTML field name.
mem_simple_ps
This tag will output the value of the posted HTML form field.
- name string HTML field name posted with the form.
Example
This example will create a form that will allow a user to add a new “Page” to Textpattern and the contents of the textarea will be parsed for Textile tags prior to saving.
<txp:mem_simple_form table="txp_page" id_field="name" id_insert="0">
<txp:mem_form_text name="string_name" label="Title" required="1" />
<br />
<txp:mem_form_textarea name="textile_user_html" label="Template" />
<br />
<txp:mem_form_submit />
</txp:mem_simple_form>
Last edited by Manfre (2010-10-03 16:19:40)
Offline
Re: mem_simple_form
- How does the plugin protect the form from HTTP request spoofing?
- IMHO, the
$form
attribute is quite never initialized.
if (!empty($form)) {
$thing = fetch_form($form);
unset($atts['form']);
}
Offline
Re: mem_simple_form
1. mem_simple_form uses mem_form, which was originally a modified/abstracted version of the form processing logic in ZCR. It uses a nonce to ensure that a form is used only once for each empty form load. Plugin developers can also create spam filters for the form in a fashion similar to ZCR. The next release (in SVN and testing) will have the ability to specify HTML fields that will not be saved to the database, which will allow for captcha’s and honeypot fields.
2. Thanks.
Offline
Re: mem_simple_form
Conclusion from initial test: Wonderful! Thanks!
Offline
Re: mem_simple_form
Two Three quick questions:
- How can I get comments to be on by default for articles submitted through
simple_form
? Comments are allowed by default in my admin prefs. Is there a field in the textpattern table I can target for this? - What’s the right way to deal with body text for an article in the textpattern table? I can get input to go into either
body
orbody_html
, but not both. - Is there another way to add a category1 other than the
mem_form_select_category
tag? I can send a string to thecategory1
field using other input methods, but it doesn’t connect.
Thank you again!
Offline
Re: mem_simple_form
1. Annotate=1
2. mem_form_hidden name=“body_html”, use javascript to populate the field from the body field on submit. (same for excerpts)
3. The string needs to be the name and not the title. E.g. “my-category” instead of “My Category”
Offline
Re: mem_simple_form
I haven’t tested this against 4.0.8, but will look in to it.
Offline
Re: mem_simple_form
Thank you, sir!
What’s the correct version of the plugin to use— v0.1 or v0.2?
Also, what fields from the textpattern
table must be informed by the plugin, my use of input fields, in order to create a record successfully?
Thanks again.
Last edited by johnstephens (2009-01-29 19:11:09)
Offline
#9 2009-02-10 03:27:18
- velograph
- New Member
- From: Oregon
- Registered: 2007-03-25
- Posts: 9
Re: mem_simple_form
I’m using this plugin to create a registration form and it’s awesome! I’m very thankful for your work on this.
I’m wondering if it’s possible to have two submit buttons?
Reason being that we’re having a regional get together and we’re wanting to let people sign up and pay now, or sign up and pay when they arrive. I’m using the mem_simple_form to collect the data, and then send it back to the page in a table using smd_query so that people can see who will be attending. Is it possible to send the info to my database and redirect the user to a paypal page that I’m creating? And then have the other button give a simple thanks message like “Thanks! See you there!”
Is this a bit out of the realm of this plugin? Or am I missing something? I’ve been poring through your documentation for a couple days now and my eyes are slightly crossed.
Either way, thanks for the awesome plugin.
Jason
Offline
Re: mem_simple_form
Jason, the plugin does not currently support that, but you might be able to work a bit of javascript magic to make it happen. You could try having each of the submit buttons change the form’s action query string before the form submits.
Offline
Re: mem_simple_form
Version 0.3 is now released.
You may now specify a “success_form”. Tags have been provided to output and compare posted values. See plugin help for full details.
Offline
#12 2009-02-10 13:31:36
- velograph
- New Member
- From: Oregon
- Registered: 2007-03-25
- Posts: 9
Re: mem_simple_form
Thanks for the reply Manfre.
I’m gonna look into that.
Last edited by velograph (2009-02-11 01:58:29)
Offline