Warning: Array to string conversion in theme_fieldset()

Created on 21 August 2023, over 1 year ago
Updated 22 August 2023, about 1 year ago

Problem/Motivation

The custom icon_selector field type is trying to use fieldset as the form's wrapper.

/**
 * Implements hook_element_info().
 */
function icon_element_info() {
  $types['icon_selector'] = array(
    '#input' => TRUE,
    '#tree' => TRUE,
    '#title' => t('Icon'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    '#default_bundle' => '',
    '#default_icon' => '',
    '#default_wrapper' => '',
    '#default_wrapper_class' => '',
    '#process' => array('form_process_fieldset', 'form_process_icon_selector'),
    '#pre_render' => array('form_pre_render_fieldset'),
    '#theme_wrappers' => array('fieldset'),
    '#attached' => array('library' => array(array('icon', 'icon_selector'))),
  );
  return $types;
}

However, it triggers the warning: "Warning: Array to string conversion in theme_fieldset()", when the form fails validation (e.g., required field empty). The reason for this is that the theme_fieldset() function expects the #value attribute to be a string. In this instance, it is:

Array
(
    [icon] => lineawesome|archive-solid
    [wrapper] => 
    [wrapper_class] => 
)

Steps to reproduce

Submit a form with the `Icon` field type and intentionally omit filling out any of the required fields on the form.

Proposed resolution

TBD

πŸ› Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States xlin1003

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024