2

I'm working in a form with five fields, but I'm only receiving the content in the comments field; I'm not getting anything from the other four, please check my code below.

<div class="form-container">
    <h3 class="aside-form__title">{{ block.contactFormHeadline }}</h3>
    {% macro errorList(errors) %}
    {% if message is defined %}
        {% if errors %}
            {% for error in errors %}
                <small class="error">{{ error }}</small>
            {% endfor %}
        {% endif %}
        {% endif %}
    {% endmacro %}
    {% from _self import errorList %}
    <form method="POST" action="">
        {{ getCsrfInput() }}
        <input type="hidden" name="action" value="contactForm/sendMessage">
        <div class="form-group">
            <input id="fromName" type="text" name="fromName" value="{% if message is defined %}{{ message.fromName }}{% endif %}" placeholder="Full Name">
            {{ message is defined and message ? errorList(message.getErrors('fromName')) }}
        </div>
        <div class="form-group">
            <input type="email" name="fromEmail" id="from-email" class="form-control" placeholder="Email" value="{% if message is defined %}{{ message.fromEmail }}{% endif %}">
            {{ message is defined and message ? errorList(message.getErrors('fromEmail')) }}
        </div>
        <div class="form-group">
            <input type="text" name="message[Company]" id="company" class="form-control" placeholder="Company Name" value="">

        </div>
        <div class="form-group">
            <input id="phone" type="text" name="message[Phone]" value="" Placeholder="Phone Number">
        </div>
        <div class="form-group">
            <textarea rows="3" cols="30" id="message" name="message" placeholder="Comments">{% if message is defined %}{{ message.message }}{% endif %}</textarea>
            {{ message is defined and message ? errorList(message.getErrors('message')) }}
        </div>
         <div class="form-group">
        <input type="submit" class="Btn mini-form" value="Submit">
         </div>
        <input type="text" name="sales" id="sales" class="hidden">
    </form>
</div>
2

When using multiple fields, you'll need to use message[body] for the main message field's name attribute. Passing just message as the name for your main text field will clobber your other custom fields that precede it, as will custom fields, if they appear after it.

I think the only fix you'll need in this case is to the “Comments” textarea:

<textarea name="message[body]">Your initial text</textarea>

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.