Our client wants a poll on the website. How can I deal with client input and update the entry? I found the Entry-Form example, but this doesn't work.

The title field is the question and the admin can add answers with a matrix field. Within the matrix fields there are 2 fields: answer and totalVotes

This is my code:

<form class="poll__questions" method="post" action="" accept-charset="UTF-8">
    <input type="hidden" name="action" value="entries/saveEntry">
    <input type="hidden" name="redirect" value="{{ craft.request.getPath }}?success=√">
    <input type="hidden" name="sectionId" value="38">
    <input type="hidden" name="entryId" value="{{ pollentry.id }}">
    <input type="hidden" name="enabled" value="1">

    {{% for answer in pollentry.answers %}
        <li><label><input type="radio" name="fields[answers][{{ answer.id }}][fields][totalVotes]" value="{{ answer.totalVotes + 1 }}"> {{ answer.answer }}</label></li>
    {% endfor %}}
    <button type="submit" class="button button--third">Vote</button>

Does anybody know why this doesn't work. It submits the form without visible errors, but it doens't update the entry.

  • 4
    The EntryModel is likely failing validation somewhere. If it is, and you check your craft/storage/runtime/logs folder, you can see where that is happening.
    – Brad Bell
    Jul 1, 2014 at 9:48
  • Did the logs help you identify your problem? Jul 12, 2014 at 5:45
  • No this didn't help me with my problem. I solved it with a plugin and not with matrix fields, but with normal fields.
    – sneeky
    Jul 13, 2014 at 9:19
  • 7
    @sneeky Would you mind sharing your solution as an answer? Asking and answering your own questions is totally legit!
    – Matt Stein
    Jul 13, 2014 at 21:33

1 Answer 1


Not an answer, but one thing that might help you diagnose the problem, is to output all the return errors (without having to define it on each field as the example templates do).

{% macro errorList(errors) %}
    {% if errors %}
        <ul class="errors">
            {% for error in errors %}
                <li>{{ error }}</li>
            {% endfor %}
    {% endif %}
{% endmacro %}

{% from _self import errorList %}

{% if account is defined %}
    {{ errorList(account.getAllErrors()) }}
{% endif %}

{% if entry is defined %}
    {{ errorList(entry.getAllErrors()) }}
{% endif %}

A User Model named 'account' is returned by default from a failed users/saveUser post action, and an Entry Model named 'entry' is returned by default from a failed entries/saveEntry post action.

I have also found the Inpector plug-in extremely helpful. You can then add {{ account | inspect }} or {{ entry | inspect }} within the if statements above to get more info.

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.