class ContactForm

Form controller for the content_entity_example entity edit forms.

Hierarchy

  • class \Drupal\content_entity_example\Form\ContactForm extends \Drupal\Core\Entity\ContentEntityForm

Expanded class hierarchy of ContactForm

Related topics

File

modules/content_entity_example/src/Form/ContactForm.php, line 14

Namespace

Drupal\content_entity_example\Form
View source
class ContactForm extends ContentEntityForm {
  
  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    /** @var \Drupal\content_entity_example\Entity\Contact $entity */
    $form = parent::buildForm($form, $form_state);
    $entity = $this->entity;
    $form['langcode'] = [
      '#title' => $this->t('Language'),
      '#type' => 'language_select',
      '#default_value' => $entity->getUntranslated()
        ->language()
        ->getId(),
      '#languages' => Language::STATE_ALL,
    ];
    return $form;
  }
  
  /**
   * {@inheritdoc}
   */
  public function save(array $form, FormStateInterface $form_state) {
    $form_state->setRedirect('entity.content_entity_example_contact.collection');
    $entity = $this->getEntity();
    return $entity->save();
  }

}

Members

Title Sort descending Modifiers Object type Summary
ContactForm::buildForm public function
ContactForm::save public function