Skip to content

Instantly share code, notes, and snippets.

Avatar

rico goldsky

View GitHub Profile
@goldsky
goldsky / emailTpl.html
Last active Aug 29, 2015
Example of email template when using dynamic field for FormIt
View emailTpl.html
<p>Hello Admin,</p>
<p>Someone has sent the application form.</p>
<table style="border: none;">
<tr>
<td colspan="3">Personal Details</td>
</tr>
<tr>
<td>Name</td>
<td>:</td>
@goldsky
goldsky / fiDynamicFieldsEmail.php
Last active Nov 27, 2016
Helper snippet to render the dynamic values from FormIt
View fiDynamicFieldsEmail.php
<?php
/**
* fiDynamicFields snippet
*
* the snippet to manipulate this dynamic form, to parse the HTML code and
* to hold the submitted values if the page goes back to the same page.
*
* @link http://www.virtudraft.com/blog/dynamic-fields-in-multiple-pages-for-formit.html
* @author goldsky <goldsky@virtudraft.com>
@goldsky
goldsky / step2DynamicFields.wrapper.html
Created Jun 21, 2014
Wrapper chunk for step-2 field of dynamic field for FormIt
View step2DynamicFields.wrapper.html
[[+dynfield.items]]
<script>
function addRow(button) {
var newRow = '[[$step2DynamicFields.item:chunkToJsProperty]]' + "&nbsp;\n";
$(newRow).insertBefore($(button));
}
function removeRow(button) {
$(button).parent().parent().remove();
}
</script>
@goldsky
goldsky / step2DynamicFields.item.html
Created Jun 21, 2014
Row chunk for step-2 field of dynamic field for FormIt
View step2DynamicFields.item.html
<div class="input-group">
<input
name="position[]"
type="text"
value="[[+dynfield.position]]"
placeholder="Past position"
required="required"
class="form-control required"
>
<span class="input-group-btn">
@goldsky
goldsky / step-2.html
Last active Aug 29, 2015
Page 2 of dynamic field for FormIt
View step-2.html
[[!FormIt?
&hooks=`email,redirect`
&emailTpl=`emailTpl`
&emailSubject=`Submission - [[+name]]`
&emailTo=`me@example.com`
&redirectTo=`10`
&validate=`position:required`
&store=`1`
&submitVar=`go`
]]
@goldsky
goldsky / step1DynamicFields.wrapper.html
Created Jun 20, 2014
Wrapper chunk for step-1 field of dynamic field for FormIt
View step1DynamicFields.wrapper.html
[[+dynfield.items]]
<script>
function addRow(button) {
var newRow = '[[$step1DynamicFields.item:chunkToJsProperty]]' + "&nbsp;\n";
$(newRow).insertBefore($(button));
}
function removeRow(button) {
$(button).parent().parent().remove();
}
</script>
@goldsky
goldsky / step1DynamicFields.item.html
Created Jun 20, 2014
Row chunk for step-1 field of dynamic field for FormIt
View step1DynamicFields.item.html
<div class="input-group">
<input
name="telephone[]"
type="text"
value="[[+dynfield.telephone]]"
placeholder="+1 800 123456"
required="required"
class="form-control required"
>
<span class="input-group-btn">
@goldsky
goldsky / chunkToJsProperty.php
Created Jun 20, 2014
Output modifier to escape HTML for javascript's value
View chunkToJsProperty.php
<?php
$output = $input;
$output = str_replace('/', '\/', $output);
$output = str_replace("\n", '', $output);
$output = preg_replace("/(>+(\s)*<+)/", '><', $output);
$output = preg_replace("/\s+/", ' ', $output);
return $output;
@goldsky
goldsky / fiDynamicFields.php
Last active Nov 27, 2016
Snippet to parse dynamic field and hold its values if the form submission returns back to the same page
View fiDynamicFields.php
<?php
/**
* fiDynamicFields snippet
*
* the snippet to manipulate this dynamic form, to parse the HTML code and
* to hold the submitted values if the page goes back to the same page.
*
* @link http://www.virtudraft.com/blog/dynamic-fields-in-multiple-pages-for-formit.html
* @author goldsky <goldsky@virtudraft.com>
@goldsky
goldsky / step-1.html
Last active Aug 29, 2015
Page 1 of dynamic field for FormIt
View step-1.html
[[!FormIt?
&hooks=`redirect`
&store=`1`
&redirectTo=`9`
&validate=`name:required,
telephone:required`
&submitVar=`go`
]]
[[!+fi.error_message:notempty=`<p>[[!+fi.error_message]]</p>`]]
<form action="[[~[[*id]]]]" method="post" class="form-horizontal" role="form">