You are here

public function PostForm::buildForm in Open Social 10.2.x

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_post/src/Form/PostForm.php \Drupal\social_post\Form\PostForm::buildForm()
  2. 8 modules/social_features/social_post/src/Form/PostForm.php \Drupal\social_post\Form\PostForm::buildForm()
  3. 8.2 modules/social_features/social_post/src/Form/PostForm.php \Drupal\social_post\Form\PostForm::buildForm()
  4. 8.3 modules/social_features/social_post/src/Form/PostForm.php \Drupal\social_post\Form\PostForm::buildForm()
  5. 8.4 modules/social_features/social_post/src/Form/PostForm.php \Drupal\social_post\Form\PostForm::buildForm()
  6. 8.5 modules/social_features/social_post/src/Form/PostForm.php \Drupal\social_post\Form\PostForm::buildForm()
  7. 8.6 modules/social_features/social_post/src/Form/PostForm.php \Drupal\social_post\Form\PostForm::buildForm()
  8. 8.7 modules/social_features/social_post/src/Form/PostForm.php \Drupal\social_post\Form\PostForm::buildForm()
  9. 8.8 modules/social_features/social_post/src/Form/PostForm.php \Drupal\social_post\Form\PostForm::buildForm()
  10. 10.3.x modules/social_features/social_post/src/Form/PostForm.php \Drupal\social_post\Form\PostForm::buildForm()
  11. 10.0.x modules/social_features/social_post/src/Form/PostForm.php \Drupal\social_post\Form\PostForm::buildForm()
  12. 10.1.x modules/social_features/social_post/src/Form/PostForm.php \Drupal\social_post\Form\PostForm::buildForm()

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

Overrides EntityForm::buildForm

1 call to PostForm::buildForm()
SocialAlbumPostForm::buildForm in modules/social_features/social_album/src/Form/SocialAlbumPostForm.php
Form constructor.
1 method overrides PostForm::buildForm()
SocialAlbumPostForm::buildForm in modules/social_features/social_album/src/Form/SocialAlbumPostForm.php
Form constructor.

File

modules/social_features/social_post/src/Form/PostForm.php, line 62

Class

PostForm
Form controller for Post edit forms.

Namespace

Drupal\social_post\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {

  // Init form mode comparison strings.
  $this
    ->setFormMode();

  // If we're rendered in a block and given a display mode then we store it
  // now because it's overwritten by ContentEntityForm::init().
  $display = $this
    ->getFormDisplay($form_state);
  $form = parent::buildForm($form, $form_state);
  $form['#attached']['library'][] = 'social_post/keycode-submit';

  // If we already have a form display mode then we simply restore that.
  if (!empty($display)) {
    $this
      ->setFormDisplay($display, $form_state);
  }
  elseif ($this->operation === 'edit') {
    $this
      ->configureViewMode($form_state);
  }

  // If this post has a visibility field then we configure its allowed values.
  if (isset($form['field_visibility'])) {
    $this
      ->configureVisibilityField($form, $form_state);
  }
  if ($this->entity
    ->isNew()) {
    unset($form['status']);
  }
  else {
    $form['status']['#access'] = $this->currentUser
      ->hasPermission('edit any post entities');
  }
  return $form;
}