/** * {@inheritdoc} */ public function save(array $form, FormStateInterface $form_state) { $entity_type = $this->getCurrentEntityType($form_state); $values = $form_state->cleanValues()->getValues(); $bundle = $form_state->get('target_bundle'); $clone_field = $values['clone_field']; $clone_field_id = NULL; // When adding a field we don't expose the Label and Id of Bundle itself. $type_label = $this->entityLabel($entity_type) . ' - ' . $this->getFieldLabel($entity_type, $bundle, $clone_field); $this->entity->set('label', $type_label); $this->entity->set('id', $this->createNewUpdateTypeName($entity_type, $clone_field)); parent::doSave($form, $form_state); $this->cloneSingleField($entity_type, $clone_field, $form_state, $bundle); $bundle_type = $this->entityTypeManager->getDefinition($entity_type) ->getBundleEntityType(); $form_state->setRedirectUrl(Url::fromRoute("entity.entity_form_display.$entity_type.default", array( $bundle_type => $form_state->get('target_bundle'), ))); }
/** * {@inheritdoc} */ public function save(array $form, FormStateInterface $form_state) { $status = parent::doSave($form, $form_state); $clone_field = $form_state->getValue('clone_field'); if ($clone_field != 'multiple-field') { $multi_field = FALSE; $this->cloneSingleField($this->entity->getUpdateEntityType(), $clone_field, $form_state); } else { $multi_field = TRUE; } switch ($status) { case SAVED_NEW: if ($multi_field) { drupal_set_message($this->t('Select fields to add to these updates')); $form_state->setRedirectUrl($this->entity->urlInfo('clone-fields')); } else { $form_state->setRedirectUrl(Url::fromRoute("entity.entity_form_display.scheduled_update.default", array( 'scheduled_update_type' => $this->entity->id(), ))); } break; default: drupal_set_message($this->t('Saved the %label Scheduled update type.', [ '%label' => $this->entity->label(), ])); $form_state->setRedirectUrl($this->entity->urlInfo('collection')); } }