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

Customize poll answers

Create poll answers with images

Say we'd want to have a poll with images as options instead of just labels.
We can add extra fields to the poll answers too.

First, in the CP, go to fields and edit the 'pollAnswerMatrix' field:


You can then edit the image field to the 'answer' block:


And in your poll's you can now add an image:


You can then render the answers in twig like:


 {% for answer in answerMatrix.all %}
<input type="radio"
   name="{{ generatePollAnswerFieldName(poll, answer) }}"
   value="{{ generatePollAnswerFieldValue(poll, answer) }}"
/>
{{ answer.label }}
{# show the image #}
{% set answerImage = answer.image.one %}
{% if answerImage %}
   <img src="{{ answerImage.url }}" />
{% endif %}
{% endfor %}