/**
  * Overrides \Drupal\Core\Entity\EntityFormController::submit().
  */
 public function submit(array $form, array &$form_state)
 {
     // Build the entity object from the submitted values.
     $entity = parent::submit($form, $form_state);
     $form_state['redirect_route']['route_name'] = 'foo_bar.list';
     return $entity;
 }
Exemple #2
0
 /**
  * Overrides \Drupal\Core\Entity\EntityForm::submit().
  */
 public function submit(array $form, array &$form_state)
 {
     // Build the entity object from the submitted values.
     $entity = parent::submit($form, $form_state);
     // Save as a new revision if requested to do so.
     if (!empty($form_state['values']['revision'])) {
         $entity->setNewRevision();
     }
     return $entity;
 }
  /**
   * {@inheritdoc}
   */
  public function submit(array $form, FormStateInterface $form_state) {
    // Build the entity object from the submitted values.
    $entity = parent::submit($form, $form_state);

    return $entity;
  }
 /**
  * {@inheritdoc}
  */
 public function submitConfigurationForm(array &$form, FormStateInterface $form_state)
 {
     // Remove button and internal Form API values from submitted values.
     parent::submit($form, $form_state);
     $this->save($form, $form_state);
 }
Exemple #5
0
 /**
  * {@inheritdoc}
  */
 public function submit(array $form, FormStateInterface $form_state)
 {
     parent::submit($form, $form_state);
     $user = $this->getEntity($form_state);
     // If there's a session set to the users id, remove the password reset tag
     // since a new password was saved.
     if (isset($_SESSION['pass_reset_' . $user->id()])) {
         unset($_SESSION['pass_reset_' . $user->id()]);
     }
 }
Exemple #6
0
 /**
  * Overrides Drupal\Core\Entity\EntityForm::submit().
  */
 public function submit(array $form, array &$form_state)
 {
     /** @var \Drupal\comment\CommentInterface $comment */
     $comment = parent::submit($form, $form_state);
     // If the comment was posted by a registered user, assign the author's ID.
     // @todo Too fragile. Should be prepared and stored in comment_form()
     // already.
     $author_name = $comment->getAuthorName();
     if (!$comment->is_anonymous && !empty($author_name) && ($account = user_load_by_name($author_name))) {
         $comment->setOwner($account);
     }
     // If the comment was posted by an anonymous user and no author name was
     // required, use "Anonymous" by default.
     if ($comment->is_anonymous && (!isset($author_name) || $author_name === '')) {
         $comment->setAuthorName($this->config('user.settings')->get('anonymous'));
     }
     // Validate the comment's subject. If not specified, extract from comment
     // body.
     if (trim($comment->getSubject()) == '') {
         // The body may be in any format, so:
         // 1) Filter it into HTML
         // 2) Strip out all HTML tags
         // 3) Convert entities back to plain-text.
         $comment_text = $comment->comment_body->processed;
         $comment->setSubject(Unicode::truncate(trim(String::decodeEntities(strip_tags($comment_text))), 29, TRUE));
         // Edge cases where the comment body is populated only by HTML tags will
         // require a default subject.
         if ($comment->getSubject() == '') {
             $comment->setSubject($this->t('(No subject)'));
         }
     }
     return $comment;
 }
Exemple #7
0
 /**
  * Updates the node object by processing the submitted values.
  *
  * This function can be called by a "Next" button of a wizard to update the
  * form state's entity with the current step's values before proceeding to the
  * next step.
  *
  * Overrides Drupal\Core\Entity\EntityForm::submit().
  */
 public function submit(array $form, array &$form_state)
 {
     // Build the node object from the submitted values.
     $node = parent::submit($form, $form_state);
     // Save as a new revision if requested to do so.
     if (!empty($form_state['values']['revision']) && $form_state['values']['revision'] != FALSE) {
         $node->setNewRevision();
         // If a new revision is created, save the current user as revision author.
         $node->setRevisionCreationTime(REQUEST_TIME);
         $node->setRevisionAuthorId(\Drupal::currentUser()->id());
     } else {
         $node->setNewRevision(FALSE);
     }
     $node->validated = TRUE;
     foreach (\Drupal::moduleHandler()->getImplementations('node_submit') as $module) {
         $function = $module . '_node_submit';
         $function($node, $form, $form_state);
     }
     return $node;
 }
 /**
  * Overrides \Drupal\Core\Entity\EntityForm::submit().
  *
  * Updates the custom block object by processing the submitted values.
  *
  * This function can be called by a "Next" button of a wizard to update the
  * form state's entity with the current step's values before proceeding to the
  * next step.
  */
 public function submit(array $form, FormStateInterface $form_state)
 {
     // Build the block object from the submitted values.
     $block = parent::submit($form, $form_state);
     // Save as a new revision if requested to do so.
     if (!empty($form_state['values']['revision'])) {
         $block->setNewRevision();
     }
     return $block;
 }