Craft CMS Poll plugin v1.3.0
Easily make polls in craft cms
More Craft plugins

Add textual user input to poll choices

New in v1.7: The user can give textual input or clarification for each of the poll choices. This is entirely optional. The textual input is not visible in the general poll statistics, but is present in the csv dowload files for the poll in the Control Panel.

With a little effort, you can add an extra field to the 'poll answers matrix' to extend it with a switch so you can choose in the poll wether the 'user input field' should appear:


Front end code
 <form method="post" action="{{ actionUrl('/poll/answer/submit') }}">
                {% set answerMatrix = poll.pollAnswerMatrix %}
                {{ csrfInput() }}
                {{ pollInputs(poll, answerMatrix) }}
                {{ redirectInput(craft.app.request.url) }}
                {% for answer in answerMatrix.all %}
                    <input type="radio"
                           name="{{ generatePollAnswerFieldName(poll, answer) }}"
                           value="{{ generatePollAnswerFieldValue(poll, answer) }}"
                    />
                    {{ answer.label }}
                    
                    {% if answer.withTextInput ?? false %}
                        specify:
                        <input type="text"
                               name="{{ generatePollAnswerTextFieldName(poll, answer) }}"
                               placeholder="specify"
                        >
                    {% endif %}
                    <hr/>
                {% endfor %}
                <button type="submit" class="btn btn-danger">Submit</button>
</form>