public function ResponseHeaderForm::form in HTTP Response Headers 2.0.x
Same name and namespace in other branches
- 8.2 src/Form/ResponseHeaderForm.php \Drupal\http_response_headers\Form\ResponseHeaderForm::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
- src/
Form/ ResponseHeaderForm.php, line 35
Class
- ResponseHeaderForm
- Form handler for the Response Header add and edit forms.
Namespace
Drupal\http_response_headers\FormCode
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
/** @var \Drupal\http_response_headers\Entity\ResponseHeader $response_header */
$response_header = $this->entity;
$form['label'] = array(
'#type' => 'textfield',
'#title' => $this
->t('Label'),
'#maxlength' => 255,
'#default_value' => $response_header
->label(),
'#description' => $this
->t("Label for the Response Header."),
'#required' => TRUE,
);
$form['id'] = array(
'#type' => 'machine_name',
'#default_value' => $response_header
->id(),
'#machine_name' => array(
'exists' => array(
$this,
'exist',
),
),
'#disabled' => !$response_header
->isNew(),
);
$form['description'] = array(
'#type' => 'textfield',
'#title' => $this
->t('Description'),
'#maxlength' => 255,
'#default_value' => $response_header
->get('description'),
'#description' => $this
->t("Description for the Response Header."),
'#required' => FALSE,
);
$form['group'] = array(
'#type' => 'textfield',
'#title' => $this
->t('Header Group'),
'#maxlength' => 255,
'#default_value' => $response_header
->get('group'),
'#description' => $this
->t("Group for the Response Header."),
'#required' => FALSE,
);
$form['name'] = array(
'#type' => 'textfield',
'#title' => $this
->t('Header name'),
'#maxlength' => 255,
'#default_value' => $response_header
->get('name'),
'#description' => $this
->t("The name for the Response Header."),
'#required' => TRUE,
);
$form['value'] = array(
'#type' => 'textfield',
'#title' => $this
->t('Header value'),
'#maxlength' => 255,
'#default_value' => $response_header
->get('value'),
'#description' => $this
->t("The value for the Response Header."),
'#required' => FALSE,
);
return $form;
}