Implements \Drupal\Core\Form\FormInterface::buildForm().
Overrides FormInterface::buildForm
public function buildForm(array $form, array &$form_state) {
$path = $this
->getCancelPath();
// Prepare cancel link.
if (isset($_GET['destination'])) {
$options = drupal_parse_url($_GET['destination']);
}
elseif (is_array($path)) {
$options = $path;
}
else {
$options = array(
'path' => $path,
);
}
drupal_set_title($this
->getQuestion(), PASS_THROUGH);
$form['#attributes']['class'][] = 'confirmation';
$form['description'] = array(
'#markup' => $this
->getDescription(),
);
$form[$this
->getFormName()] = array(
'#type' => 'hidden',
'#value' => 1,
);
$form['actions'] = array(
'#type' => 'actions',
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => $this
->getConfirmText(),
);
$form['actions']['cancel'] = array(
'#type' => 'link',
'#title' => $this
->getCancelText(),
'#href' => $options['path'],
'#options' => $options,
);
// By default, render the form using theme_confirm_form().
if (!isset($form['#theme'])) {
$form['#theme'] = 'confirm_form';
}
return $form;
}