I've the following error when I'm trying to add a new very first field into newly created entity form type.
Fatal error: Unsupported operand types in field_group/field_group.field_ui.inc on line 680
URL: /admin/structure/entityform_types/manage/test/fields
Failing code:
// If the format type is changed, make sure we have all required format settings.
if ($group->format_type != $old_format_type) {
$mode = $group->mode == 'form' ? 'form' : 'display';
$default_formatter_settings = _field_group_get_default_formatter_settings($group->format_type, $mode);
$group->format_settings += $default_formatter_settings;
$group->format_settings['instance_settings'] += $default_formatter_settings['instance_settings'];
}
Failing line:
$group->format_settings += $default_formatter_settings;
Local scope:
$bundle =
string 'test' (length=4)
$children =
array (size=1)
'' =>
array (size=0)
empty
$classes = Undefined
$default_formatter_settings =
array (size=2)
'formatter' => string '' (length=0)
'instance_settings' => null
$entity_type = string 'entityform' (length=10)
$field_group_types = Undefined
$group =
object(stdClass)[1515]
public 'label' => null
public 'children' =>
array (size=0)
empty
public 'parent_name' => null
public 'weight' => null
public 'format_type' => string 'visible' (length=7)
public 'format_settings' => int 0
So it seems the problem is that $group->format_settings is int 0, instead of expected array, so the arrays can't be merged properly.
Reproducible steps:
1. Create a new entityform type at /admin/structure/entityform_types/add (possible the same for content type): Test
1. Add a new field text and Save.
The error should appear.
Backtrace: menu_execute_active_handler/9144248 call_user_func_array()/drupal_get_form()/drupal_build_form()/drupal_process_form($form_id = 'field_ui_field_overview_form')/form_execute_handlers( $type = 'submit')/field_group_field_overview_submit()/
Comments
Comment #2
kenorb CreditAttribution: kenorb commentedComment #3
kenorb CreditAttribution: kenorb commentedThe problem is with this line:
$group->format_type = isset($form_values[$group_name]['format']['type']) ? $form_values[$group_name]['format']['type'] : 'visible';
It set
$group->format_type
to 'visible', but not such format exists.So
$default_formatter_settings = _field_group_get_default_formatter_settings($group->format_type, $mode);
is called, then_field_group_get_default_formatter_settings('visible', 'display');
is called, returning NULL in 'instance_settings' => $formatter['instance_settings'], because 'visible' format type is not valid in field_group_formatter_info();It has only 'form', and 'display':
So it generates $group such as:
where format_settings should be an array, otherwise it fails.
Comment #4
kenorb CreditAttribution: kenorb commentedThis was the problem with custom code which was adding the empty groups into form, such as: