Skip to content

Instantly share code, notes, and snippets.

View goldsky's full-sized avatar

rico goldsky

View GitHub Profile
@goldsky
goldsky / emailTpl.html
Last active August 29, 2015 14:02
Example of email template when using dynamic field for FormIt
<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 November 27, 2016 12:06
Helper snippet to render the dynamic values from FormIt
<?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 June 21, 2014 11:26
Wrapper chunk for step-2 field of dynamic field for FormIt
[[+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 June 21, 2014 11:24
Row chunk for step-2 field of dynamic field for FormIt
<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 August 29, 2015 14:02
Page 2 of dynamic field for FormIt
[[!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 June 20, 2014 05:23
Wrapper chunk for step-1 field of dynamic field for FormIt
[[+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 June 20, 2014 05:16
Row chunk for step-1 field of dynamic field for FormIt
<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 June 20, 2014 05:03
Output modifier to escape HTML for javascript's value
<?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 November 27, 2016 12:09
Snippet to parse dynamic field and hold its values if the form submission returns back to the same page
<?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 August 29, 2015 14:02
Page 1 of dynamic field for FormIt
[[!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">