Forum
use member information as default values in a perch form
When a member is signed in I would like to use their information (i.e. name, phone, email etc...) as default values in a form. Here is the code in my contact form template.
<perch:form class="nobottommargin" id="sponsorregistration" app="perch_forms" method="post" role="form">
<div class="col_one_half col_last">
<perch:label for="company">Company</perch:label>
<perch:input type="text" id="company" class="sm-form-control" value="<perch:member id="company" />" label="Company" />
</div>
<perch:success>
<div class="alert success">
<perch:content id="success" type="textarea" label="Thank you message" textile="true" editor="markitup"/>
</div>
</perch:success>
<perch:input type="submit" id="submit" value="Send" class="btn btn-primary" />
</perch:form>
Hi Justin,
I do exactly this on a client website, the way I achieved it was to grab the Perch member properties using PHP in a page template and echo them out to data attributes on a HTML element, then use JavaScript to grab these and assign them to the value of the relevant input in the form.
Javascript might be something like
Alternatively you might be able to assign these member properties to variables and pass them to the template?
https://docs.grabaperch.com/docs/templates/passing-variables-into-templates/
I haven't explored this though so can't comment on it's feasibility.
Thanks
Lee