/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { if ($form_state->get('step') == 'formatter') { $form_state->set('step', 'configuration'); $form_state->set('group_label', $form_state->getValue('label')); $form_state->set('group_name', $form_state->getValue('group_name')); $form_state->set('group_formatter', $form_state->getValue('group_formatter')); $form_state->setRebuild(); } else { $new_group = (object) array('group_name' => $form_state->get('group_name'), 'entity_type' => $this->entityTypeId, 'bundle' => $this->bundle, 'mode' => $this->mode, 'context' => $this->context, 'children' => [], 'parent_name' => '', 'weight' => 20, 'label' => $form_state->get('group_label'), 'format_type' => $form_state->get('group_formatter')); $new_group->format_settings = $form_state->getValue('format_settings'); $new_group->format_settings += _field_group_get_default_formatter_settings($form_state->get('group_formatter'), $this->context); field_group_group_save($new_group); // Store new group information for any additional submit handlers. $groups_added = $form_state->get('groups_added'); $groups_added['_add_new_group'] = $new_group->group_name; drupal_set_message(t('New group %label successfully created.', array('%label' => $new_group->label))); $form_state->setRedirectUrl(FieldgroupUi::getFieldUiRoute($new_group)); \Drupal::cache()->invalidate('field_groups'); } }
/** * {@inheritdoc} */ public function getCancelUrl() { return FieldgroupUi::getFieldUiRoute($this->fieldGroup); }