- Issue created by @braintec
- 🇯🇴Jordan yasmeensalah
The proposed resolution to the issue is working perfectly in my case.
Making it as patch to be able to apply it using composer
In some circumstances within the ui_patterns_field_group_field_group_field_overview_submit function in the ui_patterns_field_group.module file, an error occurs indicating that the value passed as the first argument to the method_exists function is null. The method_exists function requires an object or a string (the class name), but in your code, it seems that $plugin_definition['class'] may not be correctly defined or could be null.
To resolve this issue, I added a check to ensure that $plugin_definition['class'] is not null before calling method_exists. Here is how the updated code might look:
function ui_patterns_field_group_field_group_field_overview_submit(array $form, FormStateInterface $form_state) {
$field_group_form_state = $form_state->get('field_group');
if (!empty($field_group_form_state)) {
foreach ($form['#fieldgroups'] as $group_name) {
// Only save updated groups.
if (!isset($field_group_form_state[$group_name])) {
continue;
}
if (isset($field_group_form_state[$group_name]->format_settings)) {
// Retrieve the plugin definition.
$plugin_definition = \Drupal::service('plugin.manager.field_group.formatters')->getDefinition($field_group_form_state[$group_name]->format_type, FALSE);
// Ensure that $plugin_definition is not null and that the class exists.
if ($plugin_definition && isset($plugin_definition['class']) && method_exists($plugin_definition['class'], 'processFormStateValues')) {
call_user_func_array([
$plugin_definition['class'],
'processFormStateValues',
], [&$field_group_form_state[$group_name]->format_settings]);
}
}
}
// Set the form_state so that the submit hook of field_groups can work.
$form_state->set('field_group', $field_group_form_state);
}
}
Active
1.8
UI Patterns Field Group [1.x only]
The proposed resolution to the issue is working perfectly in my case.
Making it as patch to be able to apply it using composer