public function ContactFormEditForm::form in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/contact/src/ContactFormEditForm.php \Drupal\contact\ContactFormEditForm::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
- core/
modules/ contact/ src/ ContactFormEditForm.php, line 60 - Contains \Drupal\contact\ContactFormEditForm.
Class
- ContactFormEditForm
- Base form for contact form edit forms.
Namespace
Drupal\contactCode
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['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;
}