class ContactForm

Same name in other branches
  1. 3.x modules/content_entity_example/src/Form/ContactForm.php \Drupal\content_entity_example\Form\ContactForm
  2. 4.0.x modules/content_entity_example/src/Form/ContactForm.php \Drupal\content_entity_example\Form\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

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 $entity \Drupal\content_entity_example\Entity\Contact */
        $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();
        $entity->save();
    }

}

Members

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