function CommentWidget::massageFormValues

Same name and namespace in other branches
  1. 9 core/modules/comment/src/Plugin/Field/FieldWidget/CommentWidget.php \Drupal\comment\Plugin\Field\FieldWidget\CommentWidget::massageFormValues()
  2. 8.9.x core/modules/comment/src/Plugin/Field/FieldWidget/CommentWidget.php \Drupal\comment\Plugin\Field\FieldWidget\CommentWidget::massageFormValues()
  3. 11.x core/modules/comment/src/Plugin/Field/FieldWidget/CommentWidget.php \Drupal\comment\Plugin\Field\FieldWidget\CommentWidget::massageFormValues()

Overrides WidgetBase::massageFormValues

File

core/modules/comment/src/Plugin/Field/FieldWidget/CommentWidget.php, line 91

Class

CommentWidget
Provides a default comment widget.

Namespace

Drupal\comment\Plugin\Field\FieldWidget

Code

public function massageFormValues(array $values, array $form, FormStateInterface $form_state) {
  // Add default values for statistics properties because we don't want to
  // have them in form.
  foreach ($values as &$value) {
    $value += [
      'cid' => 0,
      'last_comment_timestamp' => 0,
      'last_comment_name' => '',
      'last_comment_uid' => 0,
      'comment_count' => 0,
    ];
  }
  return $values;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.