Forum

Thread tagged as: Question, Members, Shop

Perch Shop and Members - redirecting to a different URL after form submission

We're using several forms in the Perch Shop & Members combo to allow logged in members to update their addresses, personal details, account password, etc.

All the forms work, they update the information correctly. On submission the form content is replaced by the <perch:success> content. As these forms are part of the Shop & Members combo, we don't have the Forms app installed - where I'd expect to set a redirect URL once a form is submitted.

Is it possible to set a redirect URL using the form code itself? At the moment I'm adding a button link inside the <perch:success> content but it's not the best UX. This is an example template:

<perch:form id="profile" method="post" app="perch_members" class="standard-styles">

    <perch:input type="hidden" id="token" />

    <div class="form-group">
        <perch:label for="first_name">First Name</perch:label>
        <perch:input type="text" id="first_name" required="true" label="First name" class="form-control" />
        <perch:error for="first_name" type="required">Please enter your first name</perch:error>
    </div>

    <div class="form-group">
        <perch:label for="last_name">Last name</perch:label>
        <perch:input type="text" id="last_name" required="true" label="Last name" class="form-control" />
        <perch:error for="last_name" type="required">Please enter your last name</perch:error>
    </div>

    <div class="form-group">
        <perch:label for="email">Email</perch:label>
        <perch:input type="email" id="email" required="true" placeholder="you@company.com" class="form-control" />
        <perch:error for="email" type="required">Please enter your email address</perch:error>
        <perch:error for="email" type="format">Please check a your email address is correct</perch:error>
    </div>

    <perch:input type="submit" value="Update Details" class="btn btn-primary" />

    <perch:success>
        <div class="alert alert-info">
            <p>Your personal details have been successfully updated</p>
        </div>

        <div class="standard-bottom-margin">
            <a href="/members/account" class="btn btn-default">Back To Your Account</a>
        </div>
    </perch:success>

</perch:form>

Finally, I've noticed that forms required for the Shop seem to have a hidden field: <perch:input type="hidden" id="r" />, some have a URL defined as a value (e.g. value="/shop/addresses") is this a redirect?

Martin Jewiss

Martin Jewiss 0 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

I think you can use the next attribute to specify the URL on the perch:form tag.

Yes that works Drew. I need to figure out how to display a success message on the next page but teh next attribute definitely works. Thanks.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Put something on the URL that your following page can look for.