public ContactFormEditForm::form(array $form, FormStateInterface $form_state)
Gets the actual form array to be built.
Overrides EntityForm::form
See also
\Drupal\Core\Entity\EntityForm::processForm()
\Drupal\Core\Entity\EntityForm::afterBuild()
File
- core/modules/contact/src/ContactFormEditForm.php, line 69
Class
- ContactFormEditForm
- Base form for contact form edit forms.
Namespace
Drupal\contact
Code
public function form(array $form, FormStateInterface $form_state) { $form = parent::form($form, $form_state); $contact_form = $this->entity; $default_form = $this->config('contact.settings')->get('default_form'); $form['label'] = array( '#type' => 'textfield', '#title' => $this->t('Label'), '#maxlength' => 255, '#default_value' => $contact_form->label(), '#description' => $this->t("Example: 'website feedback' or 'product information'."), '#required' => TRUE, ); $form['id'] = array( '#type' => 'machine_name', '#default_value' => $contact_form->id(), '#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH, '#machine_name' => array( 'exists' => '\Drupal\contact\Entity\ContactForm::load', ), '#disabled' => !$contact_form->isNew(), ); $form['recipients'] = array( '#type' => 'textarea', '#title' => $this->t('Recipients'), '#default_value' => implode(', ', $contact_form->getRecipients()), '#description' => $this->t("Example: 'webmaster@example.com' or 'sales@example.com,support@example.com' . To specify multiple recipients, separate each email address with a comma."), '#required' => TRUE, ); $form['message'] = array( '#type' => 'textarea', '#title' => $this->t('Message'), '#default_value' => $contact_form->getMessage(), '#description' => $this->t('The message to display to the user after submission of this form. Leave blank for no message.'), ); $form['redirect'] = array( '#type' => 'path', '#title' => $this->t('Redirect path'), '#convert_path' => PathElement::CONVERT_NONE, '#default_value' => $contact_form->getRedirectPath(), '#description' => $this->t('Path to redirect the user to after submission of this form. For example, type "/about" to redirect to that page. Use a relative path with a slash in front.'), ); $form['reply'] = array( '#type' => 'textarea', '#title' => $this->t('Auto-reply'), '#default_value' => $contact_form->getReply(), '#description' => $this->t('Optional auto-reply. Leave empty if you do not want to send the user an auto-reply message.'), ); $form['weight'] = array( '#type' => 'weight', '#title' => $this->t('Weight'), '#default_value' => $contact_form->getWeight(), '#description' => $this->t('When listing forms, those with lighter (smaller) weights get listed before forms with heavier (larger) weights. Forms with equal weights are sorted alphabetically.'), ); $form['selected'] = array( '#type' => 'checkbox', '#title' => $this->t('Make this the default form'), '#default_value' => $default_form === $contact_form->id(), ); return $form; }
Please login to continue.