I have a contact form that has a checkbox so the user can choose to also be added to the newsletter subscription with their contact form submission. Basically this just needs to post a value of "y" and the client manually adds them to their mailing list.
The free version of Freeform no longer has a checkbox fieldtype (Freeform 3.x did). Freeform Pro is an awesome addon, but the only added feature I need is the checkbox field type.
Has anyone figured out a way to pass the value of a checkbox field with the free version?
I tried the Freeform Values extension: https://github.com/stovepot/freeform_values.ee_addon but I wasn't able to get it to work at all - and there is no support for it (bummer). Basically the tag I used {freeform:value:optin_check}
shows up in the html output instead of a value.
I thought maybe I could take the value of the checkbox and pass it to a hidden text field, something like this:
<input type="checkbox" id="optin_check" name="optin_check" value="Yes">
<input type="hidden" id="optin" name="optin" value="">
What I tried with the above extension:
<input type="checkbox" id="optin_check" name="optin_check" value="Yes">
<input type="hidden" id="optin" name="optin" value="{freeform:value:optin_check}">
Any ideas on how I could get something like this to work?
Complete Freeform code in my template:
{exp:freeform:form
collection="Contact"
return="/contact/thanks"
inline_errors="yes"
require_captcha="yes"
inline_error_return="contact/error"
admin_notify="[email protected]"
template="contact_us"
form:id="contact-us"
}
<p>
<label for="first_name" class="left">First Name<br>
<input type="text" value="" name="first_name" id="first_name">
</label>
<label for="last_name">Last Name<br>
<input type="text" value="" name="last_name" id="last_name">
</label>
</p>
<p>
<label for="email" class="left">Email<br>
<input type="email" value="" name="email" id="email">
</label>
<label for="confirm_email">Confirm Email<br>
<input type="email" value="" name="confirm_email" id="confirm_email">
</label>
</p>
<p>
<label for="user_message">Message<br>
<textarea rows="10" cols="20" id="user_message" name="user_message">
</textarea>
</label>
</p>
<p class="checkbox left">
<input type="checkbox" checked="checked" name="optin_check[]" value="Yes">
<label for="optin_check" class="checker">
Yes, sign me up to recieve the newsletter!
</label>
<input type="hidden" id="optin" name="optin" class="optin" value="">
</p>
{if captcha}
<p class="captcha">
<label class="long">
Please answer the security question<span class="required">*</span><br>
{captcha} <input type="text" name="captcha" id="captcha">
</label>
</p>
{/if}
<p class="left">
<input type="submit" name="submit" id="submit" value="Submit">
</p>
{/exp:freeform:form}
And here's a screenshot for the visual: