function field_group_field_ui_clone_field_groups in Field Group 8
Same name and namespace in other branches
- 8.3 includes/field_ui.inc \field_group_field_ui_clone_field_groups()
- 7.2 field_group.field_ui.inc \field_group_field_ui_clone_field_groups()
- 7 field_group.field_ui.inc \field_group_field_ui_clone_field_groups()
Submit handler to save existing fieldgroups from one view mode or form to another.
1 string reference to 'field_group_field_ui_clone_field_groups'
- field_group_field_ui_create_vertical_tabs in includes/
field_ui.inc - Create vertical tabs.
File
- includes/
field_ui.inc, line 556 - Field_group.field_ui.inc is a file that contains most functions needed on the Fields UI Manage forms (display and fields).
Code
function field_group_field_ui_clone_field_groups($form, FormStateInterface $form_state) {
$fields = array_keys($form_state
->getValue('fields'));
$source_groups = $form_state
->get('#source_groups');
if ($source_groups) {
$field_group_params = $form_state
->get('field_group_params');
foreach ($source_groups as $source_group) {
if (in_array($source_group->group_name, $fields)) {
drupal_set_message(t('Fieldgroup @group is not cloned since a group already exists with the same name.', array(
'@group' => $source_group->group_name,
)), 'warning');
continue;
}
$source_group->context = $field_group_params->context;
$source_group->mode = $field_group_params->mode;
$source_group->children = array();
field_group_group_save($source_group);
drupal_set_message(t('Fieldgroup @group cloned successfully.', array(
'@group' => $source_group->group_name,
)));
}
}
}