Skip to content

Instantly share code, notes, and snippets.

@thetristan
Created October 26, 2010 08:08
Show Gist options
  • Save thetristan/646513 to your computer and use it in GitHub Desktop.
Save thetristan/646513 to your computer and use it in GitHub Desktop.
{exp:channel:entries channel="forms" dynamic="no" entry_id="{embed:form_id}"}
{exp:nsm_transplant:body}
{!-- check if we're using the recipients feature of freeform, if so, set some variables needed for later --}
{if form_recipients}
{exp:nsm_transplant:content id="use_recipients"}yes{/exp:nsm_transplant:content}
{form_recipients}
{exp:nsm_transplant:content id="recipient{row_count}" parse="inwards"}{recipient_name}|{recipient_email}{/exp:nsm_transplant:content}
{/form_recipients}
{/if}
{!-- build out our required fields --}
{exp:nsm_transplant:content id="required_fields" parse="inwards"}
{form_fields backspace="1" search:field_required="y"}{field_field}|{/form_fields}
{/exp:nsm_transplant:content}
{!-- begin heavy lifting --}
{exp:freeform:form
collection="{form_collection}"
file_upload="{form_file_upload}"
form:id="{form_attribute_id}"
form:name="{form_attribute_name}"
form:class="{form_attribute_class}"
mailinglist="{form_mailing_list}"
mailinglist_opt_in="{form_mailing_list_opt_in}"
notify="{form_notify}"
onsubmit="{form_onsubmit}"
prevent_duplicate_on="{form_prevent_duplicate_on}"
redirect_on_duplicate="{form_redirect_on_duplicate}"
require_ip="{form_require_ip}"
required="{required_fields}"
return="{form_return}"
secure_action="{form_secure_action}"
secure_return="{form_secure_return}"
send_attachment="{form_send_attachment}"
send_user_attachment="{form_send_user_attachment}"
send_user_email="{form_send_user_email}"
status="{form_status}"
template="{form_template}"
user_email_template="{form_user_email_template}"
recipients="{use_recipients}"
recipient1="{recipient1}"
recipient2="{recipient2}"
recipient3="{recipient3}"
recipient_limit="{form_recipient_limit}"
recipient_template="{form_recipient_template}"
parse="inwards"}
{!-- warn if we have required fields --}
{if required_fields}
<p class="form-message">
<strong>IMPORTANT:</strong> Required fields are marked with an asterisk (<span class="required">*</span>)
</p>
{/if}
{!-- the actual fields loop --}
<p>{form_fields}
{!-- handle the field types we specified in the channel custom fields --}
{if field_type == "text"}
{if field_label}<label for="form_{field_field}">{field_label}{if field_required}<span class="required">*</span>{/if}</label>{/if}<input type="text" name="{field_field}" id="form_{field_field}" class="{field_class}">{if field_newline_after}</p><p>{/if}
{/if}
{if field_type == "textarea"}
{if field_label}<label for="form_{field_field}">{field_label}{if field_required}<span class="required">*</span>{/if}</label>{/if}<textarea cols="50" rows="6" name="{field_field}" id="form_{field_field}" class="{field_class}"></textarea>{if field_newline_after}</p><p>{/if}
{/if}
{if field_type == "state"}
{if field_label}<label for="form_{field_field}">{field_label}{if field_required}<span class="required">*</span>{/if}</label>{/if}<select name="{field_field}" id="form_{field_field}" class="{field_class}">
<option value=""></option>
<option value="Alabama">AL</option>
<option value="Alaska">AK</option>
<option value="Arizona">AZ</option>
...
<option value="Wyoming">WY</option>
</select>{if field_newline_after}</p><p>{/if}
{/if}
{if field_type == "country"}
{if field_label}<label for="form_{field_field}">{field_label}{if field_required}<span class="required">*</span>{/if}</label>{/if}<select name="{field_field}" id="form_{field_field}" class="{field_class}">
<option value=""></option>
<option value="Afghanistan">Afghanistan</option>
<option value="Albania">Albania</option>
<option value="Algeria">Algeria</option>
...
<option value="Zimbabwe">Zimbabwe</option>
</select>{if field_newline_after}</p><p>{/if}
{/if}
{/form_fields}</p>
{!--now that wasn't so hard, was it? --}
<p><label for="submit">&nbsp;</label><input type="submit"></p>
{/exp:freeform:form}
{/exp:nsm_transplant:body}
{/exp:channel:entries}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment