You are here

public function GoogleQRCodeAdminForm::buildForm in Google QR Code Generator 8

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/GoogleQRCodeAdminForm.php, line 32

Class

GoogleQRCodeAdminForm

Namespace

Drupal\google_qr_code\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {

  // Load configuration values
  $config = $this
    ->config('google_qr_code.settings');
  $form['google_qr_code_settings'] = array(
    '#type' => 'fieldset',
    '#title' => t('Google QR Code Configuration'),
  );
  $form['google_qr_code_settings']['google_qr_code_when_show'] = array(
    '#type' => 'select',
    '#title' => t('When to render QR COde'),
    '#options' => array(
      "on_pageload" => t('On Page Load'),
      "on_click" => t('On Click'),
    ),
    '#default_value' => $config
      ->get('whenshow') ? $config
      ->get('whenshow') : 'on_pageload',
    '#required' => FALSE,
    '#description' => t('Choose whether you want the QR code to load everytime the page loads (jQuery code) or only get the QR code when generate text in block is clicked.'),
  );
  $form['google_qr_code_image_settings'] = array(
    '#type' => 'fieldset',
    '#title' => t('Google QR Code Image Settings'),
    '#description' => t('Configure QR code width and height here. There is a
maximum size of 1000 pixels for any single dimension, and a total size
of 300,000 pixels'),
  );
  $form['google_qr_code_image_settings']['google_qr_code_height'] = array(
    '#type' => 'textfield',
    '#title' => t('QR Code Height'),
    '#default_value' => $config
      ->get('height') ? $config
      ->get('height') : 250,
    '#size' => 40,
    '#maxlength' => 255,
    '#required' => TRUE,
    '#description' => t('Enter the QR Code Height'),
  );
  $form['google_qr_code_image_settings']['google_qr_code_width'] = array(
    '#type' => 'textfield',
    '#title' => t('QR Code Width'),
    '#default_value' => $config
      ->get('width') ? $config
      ->get('width') : 250,
    '#size' => 40,
    '#maxlength' => 255,
    '#required' => TRUE,
    '#description' => t('Enter the QR Code Width'),
  );
  return parent::buildForm($form, $form_state);
}