You are here

public function PostTypeForm::form in Open Social 10.1.x

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

Gets the actual form array to be built.

Overrides EntityForm::form

See also

\Drupal\Core\Entity\EntityForm::processForm()

\Drupal\Core\Entity\EntityForm::afterBuild()

File

modules/social_features/social_post/src/Form/PostTypeForm.php, line 18

Class

PostTypeForm
Class PostTypeForm.

Namespace

Drupal\social_post\Form

Code

public function form(array $form, FormStateInterface $form_state) {
  $form = parent::form($form, $form_state);
  $post_type = $this->entity;
  $form['label'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Label'),
    '#maxlength' => 255,
    '#default_value' => $post_type
      ->label(),
    '#description' => $this
      ->t("Label for the Post type."),
    '#required' => TRUE,
  ];
  $form['id'] = [
    '#type' => 'machine_name',
    '#default_value' => $post_type
      ->id(),
    '#machine_name' => [
      'exists' => '\\Drupal\\social_post\\Entity\\PostType::load',
    ],
    '#disabled' => !$post_type
      ->isNew(),
  ];

  /* You will need additional form elements for your custom properties. */
  return $form;
}