Enables live forms in conjunction with the Import and Form plugins
live_form_defaults: |-
<div>Default Shell for the body of your form contents</div>
live_form_snippets:
form_field_name_1: # This is the field name as defined in the frontmatter of your corresponding form
field_id: 'defaults_to_field_name' # [OPTIONAL] This is the ID of an element to inject code into, if different than the field name
code: |-
<span><a id="id_of_element_to_mod">contents</a></span>
subs:
id_of_element_to_mod:
html: regex-or-string # This will replace the contents of the element with the specified id above (using jquery .html()). If omitted this will just be the form field value
attr: # list of attributes to modify (using jquery selectors)
href: regex-or-string
title: regex-or-string
style: regex-or-string
etc: ...
form_field_name_2: # This is an example of a radio field where we are placing the contents into an element with an id of the form field name
img: |-
<div>Stuff</div>
txt: |-
<div>Stuff</div>
form_field_name_3: # This is an example of a checkbox field where we are placing the contents into different elements per option
checked:
logo: |-
<td valign=middle style=border:none;padding:0><div style="text-align:left;margin:0 0 .75rem 0"><a href=http://www.tegile.com target=_blank><img height=40 src=http://webdev.tegile.com/wp-content/uploads/2015/12/logo.png></a></div>
unchecked:
company: |-
<span style="color: #1c5ea1; font-size: 13px; font-weight: bold; ">Tegile</span>
- If no rule exists, we assume the following:
- The destination fieldID will be: #live_[fieldID]
- The destination field's html will become the Source Form Field's value
- If a rule exists, we check the following:
- If the rule is a string:
- The destination field's html will become the string
- If the rule is an object:
- Any valid jQuery method can be used as a key: value pair, as long as the method is prepended by fn.. Some examples:
- The destination field's html will become the fn.html key's value, using jQuery.html()
- (It is worth noting that we will look for and process fn.html first)
- The destination field can have a class applied using the fn.addClass key, which uses the jQuery.addClass() method
- The destination field's html will become the fn.html key's value, using jQuery.html()
- Any valid jQuery method that accepts multiple parameters can be used as well, with key: value pairs beneath it. Some examples:
- fn.attr: uses jQuery.attr()
fn.attr: href: "'tel:+'+$('#desk_phone').attr('data-dial-code')+$('#desk_phone').cleanVal()" alt: some stuff title: "$('#desk_phone').cleanVal()"
- fn.css: uses jQuery.css()
fn.css: color: red padding: 0 0 0 100px
- fn.attr: uses jQuery.attr()
- The following special methods may be used as well, and will be processed in this order:
- this.action:
- Use this method if you would like to add raw jQuery or Javascript to be run when interacting with a particular field
- The this.action method may be used under any field key to be acted upon as well
- this.subs:
- Will be parsed to determine if any substitutions need to be made on the new html in the destination field
- Each substitution should have the field ID to be acted upon as a key with key: value pairs beneath it, following the same rules as the destination field (jQuery methods with leading underscore, etc...)
- There is no limit to the depth of fields with substitutions that can be chained... Just make sure you can manage your own code
- this.action:
- Any additional field to be acted upon may be specified as a key: value pair as well
-
The key must be the field ID
-
The value may be a set of key: value pairs, following the same rules as the destination field (jQuery methods with leading underscore, etc...)
-
There is no limit to the depth of fields with substitutions that can be chained... Just make sure you can manage your own code
-
The field is a Radio:
-
The field is a Checkbox:
-
The field is a Text Input:
-
- Any valid jQuery method can be used as a key: value pair, as long as the method is prepended by fn.. Some examples:
- If the rule is a string:
form field name: MUST match name of field to be acted upon
field_id: if found use as parent container id if not found, use field_name as parent container id
field types: Field types are determined by looking at the form itself, which is why the form_field_name must match the name of the form field defined in the form page frontmatter if textfield or textarea: array values are 'code' and 'subs' if radio: array values are not 'code' and 'subs', but instead must be names of the different radio options. if checkbox: array values are not 'code' and 'subs', but instead must be 'true' and 'false'.