You are here

public function Lightbox2IframeSettingsForm::buildForm in Lightbox2 8

Same name in this branch
  1. 8 src/Lightbox2IframeSettingsForm.php \Drupal\lightbox2\Lightbox2IframeSettingsForm::buildForm()
  2. 8 src/Form/Lightbox2IframeSettingsForm.php \Drupal\lightbox2\Form\Lightbox2IframeSettingsForm::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 ConfigFormBase::buildForm

File

src/Form/Lightbox2IframeSettingsForm.php, line 48
Contains \Drupal\lightbox2\Form\Lightbox2IframeSettingsForm.

Class

Lightbox2IframeSettingsForm

Namespace

Drupal\lightbox2\Form

Code

public function buildForm(array $form, \Drupal\Core\Form\FormStateInterface $form_state) {

  // Add the javascript which disables / enables form elements.
  drupal_add_js(drupal_get_path('module', 'lightbox2') . '/js/lightbox2.js', 'module');

  // Set up a hidden variable.
  $form['lightbox2_lite'] = [
    '#type' => 'hidden',
    '#value' => variable_get('lightbox2_lite', FALSE),
  ];

  // Add text box for iframe width.
  $form['lightbox2_default_frame_width'] = [
    '#type' => 'textfield',
    '#title' => t('Default width'),
    '#description' => t('The default width of the iframe in pixels.'),
    '#default_value' => variable_get('lightbox2_default_frame_width', 600),
    '#size' => 20,
  ];

  // Add text box for iframe height.
  $form['lightbox2_default_frame_height'] = [
    '#type' => 'textfield',
    '#title' => t('Default height'),
    '#description' => t('The default height of the iframe in pixels.'),
    '#default_value' => variable_get('lightbox2_default_frame_height', 400),
    '#size' => 20,
  ];

  // Add option for iframe border.
  $form['lightbox2_frame_border'] = [
    '#type' => 'checkbox',
    '#title' => t('Enable border'),
    '#description' => t('Enable iframe border.  You can modify the border style in your theme\'s css file using the iframe\'s id "lightboxFrame".'),
    '#default_value' => variable_get('lightbox2_frame_border', 1),
  ];
  return parent::buildForm($form, $form_state);
}