public function PostForm::buildForm in Open Social 8
Same name and namespace in other branches
- 8.9 modules/social_features/social_post/src/Form/PostForm.php \Drupal\social_post\Form\PostForm::buildForm()
- 8.2 modules/social_features/social_post/src/Form/PostForm.php \Drupal\social_post\Form\PostForm::buildForm()
- 8.3 modules/social_features/social_post/src/Form/PostForm.php \Drupal\social_post\Form\PostForm::buildForm()
- 8.4 modules/social_features/social_post/src/Form/PostForm.php \Drupal\social_post\Form\PostForm::buildForm()
- 8.5 modules/social_features/social_post/src/Form/PostForm.php \Drupal\social_post\Form\PostForm::buildForm()
- 8.6 modules/social_features/social_post/src/Form/PostForm.php \Drupal\social_post\Form\PostForm::buildForm()
- 8.7 modules/social_features/social_post/src/Form/PostForm.php \Drupal\social_post\Form\PostForm::buildForm()
- 8.8 modules/social_features/social_post/src/Form/PostForm.php \Drupal\social_post\Form\PostForm::buildForm()
- 10.3.x modules/social_features/social_post/src/Form/PostForm.php \Drupal\social_post\Form\PostForm::buildForm()
- 10.0.x modules/social_features/social_post/src/Form/PostForm.php \Drupal\social_post\Form\PostForm::buildForm()
- 10.1.x modules/social_features/social_post/src/Form/PostForm.php \Drupal\social_post\Form\PostForm::buildForm()
- 10.2.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
File
- modules/
social_features/ social_post/ src/ Form/ PostForm.php, line 30
Class
- PostForm
- Form controller for Post edit forms.
Namespace
Drupal\social_post\FormCode
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);
}
return $form;
}