Skip to content
● Grav 2.2 is out: 2x faster cold starts and 96% less memory on big sites. Read the announcement →

Checkboxes Returning "Array" Instead of Keys or Option Values

form

Started by BG Jessop 7 years ago · 0 replies · 717 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 Japhy, 2 weeks ago
2 261 4 days ago
Forms & Blueprints · by FrViPofm, 4 weeks ago
5 326 4 weeks ago
Forms & Blueprints · by Ton Haarmans, 6 years ago
13 2317 8 months ago
Forms & Blueprints · by Hugo Oliveira, 9 months ago
0 779 9 months ago
Forms & Blueprints · by Flachy Joe, 10 months ago
9 868 10 months ago