This plugin let you to create and insert in any place your contact forms by a single shortcode.
Each contact permit to add fields like:
Embed:
To embed a form in your content, you need to copy the shorcode like " [forms slug=home-contact]" and paste in any place of your content.
When a contact form was submitted, you will receive an email in your configured email and also it will be saved in to DB to see in the contact forms list.
This plugin include control and securities to avoid machine or robot submissions and also works great if you are caching the page.
Hooks:
To customize the render of fields, you can change from plugins or themes by listening a hook called "contact_form_item_render".
This hook receive a Hash a argument:
{
field: Field Object,
form: Form Object,
template: default template,
custom_class: "form-control <custom class defined in the form>", //html class for html field (select, input, ..)
custom_attrs: {id } // html attributes for the html field (select, input, ..)
}
Default template:
"<div class='form-group'>
<label>[label ci]</span></label>
<p>[descr ci]</p> //This is present only if description was defined
<div>[ci]</div>
</div>"
Where:
Sample:
def my_theme_contact(args)
args[:template] = "[ci]" //show only field
args[:custom_class] += " animate bounceIn " //adding custom class to the field
args[:custom_attrs]["data-delay"] = "500" //adding custom attribute to the field
args[:custom_attrs]["placeholder"] = args[:field][:label] //adding placeholder to the field
end
Also you can customize the form by listening the hook "contact_form_render", this hook manage the following attributes:
form: (Form Object) The current form model,
form_class: (String) the class name for the for tag (default: railscf-form railscf-form-group),
before_form: (String) html elements to be inserted before the form tag
after_form: (String) html elements to be inserted after the form tag
submit: (String) This is the template for the submit button panel, default:
<div class='form-group'>
<button class='submit_btn btn btn-default pull-right' type='submit'>[submit_label]</button>
</div>
Sample:
def camaleon_cms_contact_render(args)
args[:submit] = "<label><span> </span>
<button class='submit_btn animate swing' data-delay='1000' id='submit_btn'>[submit_label]</button>
</label>"
args[:before_form] = "<div class='contact'> <div class='form form3 animate bounceInUp'> <fieldset id='contact_form'>"
args[:after_form] = "</fieldset> </div> </div>"
end
Mark Siemers
December 28, 2015 17:25Placing the shortcode in content works great. Is there are way to embed the forms in a view partial?