public function LinkCheckerLinkForm::form in Link checker 8
Gets the actual form array to be built.
Overrides ContentEntityForm::form
See also
\Drupal\Core\Entity\EntityForm::processForm()
\Drupal\Core\Entity\EntityForm::afterBuild()
File
- src/
Form/ LinkCheckerLinkForm.php, line 49
Class
- LinkCheckerLinkForm
- Form handler for the linkchecker link edit forms.
Namespace
Drupal\linkchecker\FormCode
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
/** @var \Drupal\linkchecker\Entity\LinkCheckerLink $link */
$link = $this->entity;
$form['settings'] = [
'#type' => 'details',
'#title' => $this
->t('Settings'),
'#description' => $this
->t('The link <a href=":url">:url</a> was last checked on @last_checked and failed @fail_count times.', [
':url' => $link
->getUrl(),
'@fail_count' => $link
->getFailCount(),
'@last_checked' => $this->dateFormatter
->format($link
->getLastCheckTime()),
]),
'#open' => TRUE,
];
$form['settings']['method'] = [
'#type' => 'select',
'#title' => $this
->t('Select request method'),
'#default_value' => $link
->getRequestMethod(),
'#options' => [
'HEAD' => $this
->t('HEAD'),
'GET' => $this
->t('GET'),
],
'#description' => $this
->t('Select the request method used for link checks of this link. If you encounter issues like status code 500 errors with the HEAD request method you should try the GET request method before ignoring a link.'),
];
$form['settings']['status'] = [
'#default_value' => $link
->isLinkCheckStatus(),
'#type' => 'checkbox',
'#title' => $this
->t('Check link status'),
'#description' => $this
->t('Uncheck if you wish to ignore this link. Use this setting only as a last resort if there is no other way to solve a failed link check.'),
];
return $form;
}