1

I'm using the built in contact form, but the only element that gets emailed is the message. Nothing else.

{exp:email:contact_form user_recipients="no" recipients="nick@pixelsandcode.co.uk" charset="utf-8" form_class="form form--full"}
    <p id = "ajax-message"></p>
    <fieldset class="controls">
        <label for="from" class="controls__label">Your Email:</label><br />
        <input class="controls__control" type="text" id="from" name="from" size="40" maxlength="35" value="{member_email}" />
    </fieldset>
    <fieldset class="controls">
        <label for="budget" class="controls__label">Your Budget:</label><br />
        <input type="hidden" name="budget[]" value="--Your Budget--" />
        <input class="" type="range" name="budget" id="budget" min="1000" max="10000" step="1000" value="3000" oninput="outputUpdate(value)" list="ticks" />
        <datalist id="ticks">
            <option>1000</option>
            <option>2000</option>
            <option>3000</option>
            <option>4000</option>
            <option>5000</option>
            <option>6000</option>
            <option>7000</option>
            <option>8000</option>
            <option>9000</option>
            <option>10000</option>
        </datalist>
        <output for="range" id="your_budget" class="output">£3000</output>
        <script>
            function numberWithCommas(x) {
                return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
            }
            function outputUpdate(amount) {
                document.querySelector('#your_budget').value = "£"+numberWithCommas(amount);
            }

        </script>
    </fieldset>
    <fieldset class="controls">
        <label for="message" class="controls__label">Message:</label><br />
        <input type="hidden" name="message[]" value="--Message--" />
        <textarea class="controls__control" id="message" name="message" rows="18" cols="40"></textarea>
    </fieldset>
    <fieldset class="controls">
        <label for="extra" class="controls__label">Extra:</label><br />
        <input type="hidden" name="extra[]" value="--Extra--" />
        <textarea class="controls__control" id="extra" name="extra" rows="18" cols="40"></textarea>
    </fieldset>
    <fieldset class="controls">
        <input name="submit" type='submit' value='Submit Form' class="btn btn--primary" />
    </fieldset>
{/exp:email:contact_form}

What am I doing wrong here?

1

The Email module doesn't know what to do with arbitrary POST data, it can only recognize fields that it is looking for. To build an email from multiple fields, use only the message field, but as an array. e.g.:

<input type="text" name="message[]" />
<textarea name="message[]"></textarea>
| improve this answer | |
  • ah I see. Let me try that. – Nick Toye Apr 16 '15 at 16:47
  • Ok, I think I am still confused. This is my code now: <fieldset class="controls"> <label for="message" class="controls__label">Message:</label><br /> <input type="hidden" name="message[]" value="--Message--" /> <textarea class="controls__control" id="message" name="message" rows="18" cols="40"></textarea> </fieldset> <fieldset class="controls"> <label for="extra" class="controls__label">Extra:</label><br /> <input type="hidden" name="message[]" value="--Extra--" /> <textarea class="controls__control" id="extra" name="extra" rows="18" cols="40"></textarea> </fieldset> not working. – Nick Toye Apr 16 '15 at 16:51
  • Your textarea needs a name of message[] as well instead of message. – Derek Jones Apr 16 '15 at 16:57
  • Ok that works now. It's quite basic isn't it? The email form is only going to me so I don't mind the lack of styling, but not sure any of my clients would be too happy with it. But all good for now. – Nick Toye Apr 16 '15 at 16:59
  • Well you can use that technique with any of the fields you want to use to build the message, not just those, complete apart from styling. Just a note that datalist I don't think is supported in Safari. caniuse.com/#search=datalist – Derek Jones Apr 16 '15 at 17:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.