public function SocialAlbumPostForm::buildForm in Open Social 10.1.x
Same name and namespace in other branches
- 10.3.x modules/social_features/social_album/src/Form/SocialAlbumPostForm.php \Drupal\social_album\Form\SocialAlbumPostForm::buildForm()
- 10.0.x modules/social_features/social_album/src/Form/SocialAlbumPostForm.php \Drupal\social_album\Form\SocialAlbumPostForm::buildForm()
- 10.2.x modules/social_features/social_album/src/Form/SocialAlbumPostForm.php \Drupal\social_album\Form\SocialAlbumPostForm::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.
\Drupal\node\NodeInterface|null $node: (optional) The node entity object. Defaults to NULL.
Return value
array The form structure.
Overrides PostForm::buildForm
File
- modules/
social_features/ social_album/ src/ Form/ SocialAlbumPostForm.php, line 51
Class
- SocialAlbumPostForm
- Provides form for creating a post in an album.
Namespace
Drupal\social_album\FormCode
public function buildForm(array $form, FormStateInterface $form_state, NodeInterface $node = NULL) {
$this->node = $node;
$form = parent::buildForm($form, $form_state);
if ($node) {
$form['#disable_inline_form_errors'] = TRUE;
$form['field_album']['widget']['value']['#default_value'] = $node
->id();
$form['field_album']['#access'] = FALSE;
$form['field_post_image']['widget'][0]['#required'] = TRUE;
}
return $form;
}