Tue Feb 10, 2009
Textpattern mem_simple_form Plugin
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
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>
file:
mem_simple_form.gz.txt [4.99KB]
Category: Textpattern
download: 497
file:
mem_simple_form.txt [14.47KB]
Category: Textpattern
download: 479
Comment
Commenting is closed for this article.





