0

Help, please! I'm getting the following error code:

Notice: Array to string conversion in wf_crm_admin_component::preprocessComponentsForm() (line 555 of /home/makom/www/www/sites/all/modules/webform_civicrm/includes/wf_crm_admin_component.inc).

Here is the code in question, line 555 is the last line of text, which starts "$type = array." I'm not by any means a PHP expert, can anyone help me parse this issue, and if not fix it, at least understand what it means?

  // Component row
  elseif (!empty($row['data-cid']) && isset($node->webform['components'][$row['data-cid']])) {
    $cid = $row['data-cid'];
    $component = $node->webform['components'][$cid];
    $type = &$row['data'][1];
    if ($component['type'] == 'civicrm_contact') {
      $types = array(
        'autocomplete' => t('Contact - Autocomplete'),
        'select' => t('Contact - Select List'),
        'hidden' => $component['extra']['show_hidden_contact'] ? t('Contact - Static') : t('Contact - Hidden'),
      );
      $type = $types[$component['extra']['widget']];
    }
    elseif ($component['type'] == 'select') {
      if ($component['extra']['aslist']) {
        $type = $component['extra']['multiple'] ? t('Multi-select') : t('Select');
      }
      else {
        $type = $component['extra']['multiple'] ? t('Checkboxes') : t('Radio buttons');
      }
    }
    if (in_array($cid, $enabled)) {
      $fields = wf_crm_get_fields();
      $sets = wf_crm_get_fields('sets');
      $class = 'civi-icon';
      list( , $c, $ent, $n, $table, $name) = explode('_', $component['form_key'], 6);
      $field = wf_crm_aval($fields, $table . '_' . $name, array('type' => 'fieldset'));
      // Don't allow CiviCRM fields to be cloned
      $row['data'][6] = '';
      if ($component['type'] == 'fieldset') {
        $title = t('Contact !num', array('!num' => $c));
        $type = t('Fieldset for !contact', array('!contact' => wf_crm_contact_label($c, $data)));
        $row['data'][6] = l(t('Clone Contact'), "node/{$node->nid}/webform/components/$cid/clone", array(
          'attributes' => array('title' => t('Add a new contact to the form with the same fields and settings')
          )));
        $class .= ' fieldset';
      }
      elseif ($ent == 'contact') {
        $field_type = ($table == 'contact' || $table == 'other') ? $field['name'] : $sets[$table]['label'];
        $title = t('!type Field for !contact', array('!contact' => wf_crm_contact_label($c, $data), '!type' => $field_type));
      }
      else {
        $title = t('Field for !type', array('!type' => $sets[$table]['label']));
      }
      if ($table === 'address' && $component['type'] === 'textfield') {
        if ($name === 'state_province_id' || $name === 'county_id') {
          $type = t('AJAX Select');
        }
      }
      if ($component['type'] == 'civicrm_contact' || $component['type'] == 'fieldset') {
        $class .= ' ' . $node->webform_civicrm['data']['contact'][$c]['contact'][1]['contact_type'];
      }
      if ($component['type'] == 'select') {
        $type .= ' (' . (empty($component['extra']['civicrm_live_options']) ? t('static') : t('live')) . ')';
      }
      // Show defaults with labels instead of keys
      if ($component['type'] == 'civicrm_contact') {
        if ($component['extra']['default'] == 'contact_id') {
          $row['data'][2] = check_plain(wf_crm_display_name($component['extra']['default_contact_id']));
        }
        elseif ($component['extra']['default'] == 'user') {
          $row['data'][2] = t('Current User');
        }
        elseif ($component['extra']['default'] == 'auto') {
          $row['data'][2] = t('Auto - From Filters');
        }
        elseif ($component['extra']['default'] == 'relationship' && $component['extra']['default_relationship']) {
          $row['data'][2] = t('Relationship to !contact', array('!contact' => wf_crm_contact_label(1, $data)));
        }
      }
      elseif (isset($component['value']) && strlen($component['value']) && ($field['type'] == 'select' || !empty($field['expose_list']))) {
        if ($component['type'] == 'select') {
          $items = wf_crm_str2array($component['extra']['items']);
        }
        else {
          $items = wf_crm_field_options($component, 'components_form', $node->webform_civicrm['data']);
        }
        $val = '';
        foreach (explode(',', $component['value']) as $v) {
          if (isset($items[trim($v)])) {
            $val .= ($val ? ', ' : '') . $items[trim($v)];
          }
        }
        $row['data'][2] = $val;
      }
      // Contribution page - link to civicrm config form instead of component edit form
      if ($name == 'contribution_page_id') {
        $type = t('CiviCRM Billing Fields');
        $class .= ' contribution';
        $row['data'][5] = l(t('Configure'), 'civicrm/admin/contribute/settings', array(
          'query' => array(
            'reset' => 1,
            'action' => 'update',
            'id' => $component['value'],
          ),
          'attributes' => array(
            'title' => t('Edit Contribution Page in CiviCRM'),
          )
        ));
      }
      $type = array('data' => '<span class="' . $class . '"> </span>' . $type, 'title' => $title);
    }
  }
}

}

1 Answer 1

0

It's important to understand the difference between errors and notices. The message you're seeing says "Notice Array to string conversion" so it is not an error. Notices are just info to programmers pointing out something they could do better and are generally harmless. Your Drupal site should be configured to not display notices to your users (you can just hide them in the admin settings).

As for what exactly is causing it... I squinted at the line of code you pasted in but don't see anything wrong with it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.