Skip to content
● Meet Grav Guard: keep every Grav site you run secure and up to date, all from one place. Free for up to 3 sites. Read more →

Checkboxes Returning "Array" Instead of Keys or Option Values

form

Started by BG Jessop 8 years ago · 0 replies · 792 views
8 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 TomW, 4 weeks ago
3 323 4 weeks ago
Forms & Blueprints · by Japhy, 2 months ago
2 555 1 month ago
Forms & Blueprints · by FrViPofm, 2 months ago
5 558 2 months ago
Forms & Blueprints · by Ton Haarmans, 6 years ago
13 2549 9 months ago
Forms & Blueprints · by Hugo Oliveira, 10 months ago
0 984 10 months ago