Skip to content
Grav 2.1 is out: every page speaks Markdown. Read the announcement →

Checkboxes Returning "Array" Instead of Keys or Option Values

form

Started by BG Jessop 7 years ago · 0 replies · 681 views
7 years ago

My form has always worked using radio select for a certain field. Changed the field to checkboxes and cannot get the option values to save. It keeps giving me fieldname: Array or a null value.

For field output to a txt file, I use body: 'fieldname: {{ form.value.fieldname }}' and sometimes appended with |raw and never had a problem before.

I've tried use: keys and even edited the checkboxes section of the data.html.twig with the following ul:

TWIG
{% set use_keys = field.use is defined and field.use == 'keys' %}
    {% for key,value in form.value(field.name) %}
        {% set index = (use_keys ? key : value) %}
        <li>{{ field.options[index]|e }}</li>
    {% endfor %}

and:

TWIG
                        {% for value in form.value(field.name) %}
                            <li>{{ field.options[value]|e }}</li>
                        {% endfor %}

As well, I tried submitting the form using many different combinations to no avail.

Suggested topics

Topic Participants Replies Views Activity
Forms & Blueprints · by FrViPofm, 4 days ago
5 86 4 days ago
Forms & Blueprints · by Ton Haarmans, 6 years ago
13 2113 7 months ago
Forms & Blueprints · by Hugo Oliveira, 8 months ago
0 597 8 months ago
Forms & Blueprints · by Flachy Joe, 9 months ago
9 690 9 months ago
Forms & Blueprints · by Augustus, 10 months ago
7 737 10 months ago