Search

I did a search for this seemingly basic problem but couldn't find any answers. I have a contact form up & running (and working) on my test site, but I want to make the Email address field optional. I've pasted my code below but I've specifically tried to edit this bit below, to no avail:

    <input class="text-input" type="email" id="email" name="fields[email]" required="required" placeholder="E-mail address"/>

I've tried changing required="required" to various other parameters as well as removing it completely but the emails either won't send or still require an email address when clicking submit.

The form:

    <form method="post" action="" enctype="multipart/form-data">
<fieldset>
<label for="name">Name</label>
<input class="text-input" type="text" id="name" name="fields[from]" required="required" placeholder="Your name"/>
<label for="email">E-mail</label>
<input class="text-input" type="email" id="email" name="fields[email]" required="required" placeholder="E-mail address"/>
<label for="message">Your Message</label>
<textarea class="text-input" id="message" name="fields[body]" rows="9" cols="30" required="required"></textarea>
<input name="send-email[sender-email]" value="fields[email]" type="hidden" />
<input name="send-email[sender-name]" value="fields[from]" type="hidden" />
<input name="send-email[subject]" value="You are being contacted" type="hidden" />
<input name="send-email[body]" value="fields[body]" type="hidden" />
<input name="send-email[recipient]" value="admin" type="hidden" /><br/>
<!--<input name="redirect" type="hidden" value="{$root}/contact/success/" />-->

<input class="button send" id="submit" type="submit" name="action[save-message]" value="Send Message" />
</fieldset>

Any help very appreciated

I presume you're saving the email into a Text Input field in your section. If so, go to Blueprints > Sections and un-tick the "required" checkbox against this field. Does that change anything?

Hi Nick, thanks for the reply.

Sorry, should've said - yep it's going to a text input which isn't a required field.

I still haven't managed to solve this, any help would be really appreciated - it's probably something fairly simple

send-email[sender-email] is optional so the form shouldn't fail if it's omitted.

For clarity I presume you have:

  • removed the required="required" from the HTML
  • ensured that the Email text field isn't required in the Symphony section

Can you change the form action to ?debug so you can see the save-message event output on submit. What do you see?

Hi Nick, yep can confirm both of those things, and here's the output:

        <save-message result="error">
        <filter name="akismet" status="failed">Author and Email field mappings are required.</filter>
        <post-values>
            <from>John</from>
            <body>Testing again</body>
        </post-values>
        <message>Entry encountered errors when saving.</message>
    </save-message>
filter name="akismet"...

Oh, this is the Akismet plugin then. Akismet require that you submit both an author name and an email address for it to check spam. Check the documentation in your event (Blueprints > Events) to see how to set the Akismet field mappings. They work in the same way as the Send Notification Email (send-email[field]) mappings.

It seems that if you want to use the Akismet filter on your event, you will have to make Email a required field.

Ah that did the trick. I'll give it a trial without Akismet for a while and see how it goes.

Thanks :)

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details