So I am building this "booking form" (really it just emails somebody) and I want the form to be pre-populated with the user's details if they are logged in. I have this mostly working, but the email address will not populate from the global {email}
variable.
Because of the parse order I have the form in an include and am embedding it in my template, passing the variables to it.
Here is the embed code:
{embed="/includes/.booking-form"
first-name="default_value='{exp:member:custom_profile_data}{first-name}{/exp:member:custom_profile_data}'"
last-name="default_value='{exp:member:custom_profile_data}{last-name}{/exp:member:custom_profile_data}'"
email="default_value='{email}'"
school="default_value='{exp:member:custom_profile_data}{school}{/exp:member:custom_profile_data}'"
}
And here is the form code:
{exp:freeform:form form_id="1" required="first_name|last_name|email|school" return="{page_url}" inline_errors="yes" form:class="booking-form"}
{if freeform:general_errors}
<h2>There were some error(s) with your submission:</h2>
<ul>
{freeform:general_errors}
<li>{freeform:error_message}</li>
{/freeform:general_errors}
</ul>
{/if}
<p>
<label><span>*</span> First name:</label>
{freeform:field:first_name {embed:first-name}}
{if freeform:error:first_name}
<span class="error">
{freeform:error:first_name}
</span>
{/if}
</p>
<p>
<label><span>*</span> Last name:</label>
{freeform:field:last_name {embed:last-name}}
{if freeform:error:last_name}
<span class="error">
{freeform:error:last_name}
</span>
{/if}
</p>
<p>
<label><span>*</span> Email:</label>
{freeform:field:email {embed:email}}
{if freeform:error:email}
<span class="error">
{freeform:error:email}
</span>
{/if}
</p>
<p>
<label><span>*</span> Your school:</label>
{freeform:field:school {embed:school}}
{if freeform:error:school}
<span class="error">
{freeform:error:school}
</span>
{/if}
</p>
<p>
<label>Comments:</label>
{freeform:field:comments}<br />
{if freeform:error:comments}
<span class="error">
{freeform:error:comments}
</span>
{/if}
</p>
<p class="submit">{freeform:submit}</p>
{/exp:freeform:form}
As I said, the first name, last name and school are pre-populating perfectly, it is only the email that is not working. I have done a bit of debugging, if I put the {embed:email}
tag in elsewhere in the code it outputs correctly default_value='[email protected]'
, and if I manually type in the email into the embed code like so:
email="default_value='[email protected]'"
it pre-populates.
Anyone have any idea what's going on? Thanks in advance!