getgrav / grav-plugin-admin

Grav Admin Plugin
http://getgrav.org
MIT License
355 stars 223 forks source link

Array to string conversion by switching PHP Version #2350

Open chwebcloud opened 1 year ago

chwebcloud commented 1 year ago

I switched to PHP 8.0. On other projects it worked flawlessly. Everything in the admin area seems to work, except for the content management (pages). Temporarily I switched to PHP 7.4 to work with GRAV. However, in this project I get the following error:

An exception has been thrown during the rendering of a template ("Array to string conversion").

/user/plugins/form/templates/forms/fields/select/select.html.twig

                    value="{{ akey }}"
                >
                    {{ avalue|raw }}
                </option>
            {% elseif item_value is iterable %}
                {% set optgroup_label = item_value|keys|first %}
                <optgroup label="{{ optgroup_label|t|e('html_attr') }}">
                  {% for subkey, suboption in field.options[key][optgroup_label] %}
                      {% set subkey = subkey|string %}
                      {% set item_value = (field.selectize and field.multiple ? suboption : subkey)|string %}
                      {% set selected = (field.selectize ? suboption : subkey)|string %}
                      <option {% if subkey is same as (value) or (field.multiple and selected in value) %}selected="selected"{% endif %} value="{{ subkey }}">
                        {{ suboption|t|raw }}
                      </option>
                  {% endfor %}
                </optgroup>
            {% else %}
                {% set val = (field.selectize and field.multiple ? item_value : key)|string %}
                {% set selected = (field.selectize ? item_value : key)|string %}
                <option {% if val is same as (value) or (field.multiple and selected in value) %}selected="selected"{% endif %} value="{{ val }}">{{ item_value|t|raw }}</option>
            {% endif %}
        {% endfor %}

    </select>
</div>

{% endblock %}

Arguments

"An exception has been thrown during the rendering of a template ("Array to string conversion")."
rhukster commented 1 year ago

Runs fine for me on PHP 7.4, most likely you have some php cached by opcache. Try restarting your PHP-FPM (if you use that) or Apache.

chwebcloud commented 1 year ago

Yes, everything works fine in PHP 7.4. The error occurs with PHP 8.0 Thanks for your Support! Tom