You are here

public function PdfLinksConfigurationForm::buildForm in Printer and PDF versions for Drupal 8+ 8

Same name and namespace in other branches
  1. 2.x src/Form/PdfLinksConfigurationForm.php \Drupal\printable\Form\PdfLinksConfigurationForm::buildForm()

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

Overrides FormInterface::buildForm

File

src/Form/PdfLinksConfigurationForm.php, line 68

Class

PdfLinksConfigurationForm
Provides shared configuration form for all printable formats.

Namespace

Drupal\printable\Form

Code

public function buildForm(array $form, FormStateInterface $form_state, $printable_format = NULL) {
  $form['settings']['print_pdf_link_pos'] = [
    '#type' => 'checkboxes',
    '#title' => 'Link location',
    '#default_value' => [],
    '#options' => [
      'node' => $this
        ->t('Links area'),
      'comment' => $this
        ->t('Comment area'),
      'user' => $this
        ->t('User area'),
    ],
    '#description' => $this
      ->t('Choose the location of the link(s) to the printer-friendly version pages. The Links area is usually below the node content, whereas the Comment area is placed near the comments. The user area is near the user name. Select the options for which you want to disable the link. If you select any option then it means that you have enabled printable support for that entity in the configuration tab.'),
  ];
  foreach ($this
    ->config('printable.settings')
    ->get('printable_pdf_link_locations') as $link_location) {
    $form['settings']['print_pdf_link_pos']['#default_value'][] = $link_location;
  }
  $form['settings']['submit'] = [
    '#type' => 'submit',
    '#value' => 'Submit',
  ];
  return $form;
}