Forum

Thread tagged as: Question, Problem, Addons

Form showing error messages before any input

Hi,

I'm trying to create a form but instead of the input fields appearing my error messages appear on the page when it loads:

<perch:form id="whitepaper-signup" method="post" app="perch_forms">
                <div class="input-field">
                    <perch:label for="name">Name</perch:label>
                    <perch:input type="text" id="name" required="true" label="Name"  antispam="name" />
                    <perch:error for="name" type="required">Please add your name</perch:error>
                </div>
                <div class="input-field">
                    <perch:label for="email">Email</perch:label>
                    <perch:input type="email" id="email" required="true" label="Email" antispam="email" />
                    <perch:error for="email" type="required">Please add your email address</perch:error>
                    <perch:error for="email" type="format">Please check your email address</perch:error>
                </div>
                <div class="bot-check">
                    <perch:input type="text" id="bot-check" antispam="honeypot" label="This is a spam check - please leave blank if you are human"/>
                </div>
                <div class="input-button">
                     <perch:input type="hidden" id="signupURL" value="perch_blog_post_field(perch_get('s'), 'whitepaperURL')" />
                    <perch:input type="submit" id="submit" value="Send" />
                </div>
                <perch:success>
                    <p>Thank you. A copy of our whitepaper will be emailed to you shortly.</p>
                </perch:success>
            </perch:form>

I'm using a similar comments form and that appears correctly. What am I doing wrong?

Nick Capehorn

Nick Capehorn 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Which page function are you using to display it?

I'm in a page within my blog. All I want to do is accept a name and email address and then call a third party - I'm wondering whether I need the forms app?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Have you put template code directly into your page?

A bit more info. I have a blog type called whitepapers. I want a User to be able to request a copy of each whitepaper by entering their email address and name into a form on the page which displays the actual blog post. A link to the whitepaper is emailed out via Campaign Monitior but it's not included in Perch it's done by calling campaign monitor and passing the details.

Originally I put the form into the template file for a whitepaper post as I wanted to include some variable content on the form but I found that none of my fields were appearing on the page at all.

I left those fields in but took out the form and tried putting it below the template in the php file. Now the form is appearing correctly except that the errors and showing before it has been submitted.

I'm fairly new to this and so any advice would be appreciated.....

Drew McLellan

Drew McLellan 2638 points
Perch Support

Which file is your form in?

it's in post.php in a folder called whitepapers, which is in the pages folder.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Forms need to go in a template, rather than a page.

For blog, you could put the form in your post.html template.