Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Forms & Blueprints

Checkboxes Returning "Array" Instead of Keys or Option Values

form

Started by BG Jessop 7 years ago · 0 replies · 519 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 Ton Haarmans, 5 years ago
13 1136 4 months ago
Forms & Blueprints · by Hugo Oliveira, 5 months ago
0 61 5 months ago
Forms & Blueprints · by Flachy Joe, 6 months ago
9 135 6 months ago
Forms & Blueprints · by Augustus, 7 months ago
7 110 7 months ago
Forms & Blueprints · by Julien, 7 months ago
10 129 7 months ago