You are here

function PageUrlQrCodeBlock::blockForm in Page URL QR Code Block 8

Returns the configuration form elements specific to this block plugin.

Blocks that need to add form elements to the normal block configuration form should implement this method.

Parameters

array $form: The form definition array for the block configuration form.

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

Return value

array The renderable form array representing the entire configuration form.

Overrides BlockPluginTrait::blockForm

File

src/Plugin/Block/PageUrlQrCodeBlock.php, line 56
Contains \Drupal\page_url_qr_code_block\Plugin\Block\page_url_qr_code_block.

Class

PageUrlQrCodeBlock
Provides my custom block.

Namespace

Drupal\page_url_qr_code_block\Plugin\Block

Code

function blockForm($form, FormStateInterface $form_state) {
  $form = parent::blockForm($form, $form_state);
  $config = $this
    ->getConfiguration();
  $form['page_url_qr_code_caption'] = array(
    '#type' => 'textfield',
    '#title' => t('Caption'),
    '#description' => t('Will display under the QR Code'),
    '#default_value' => isset($config['page_url_qr_code_caption']) ? $config['page_url_qr_code_caption'] : 'Page URL',
  );
  $form['page_url_qr_code_alt'] = array(
    '#type' => 'textfield',
    '#title' => t('Alt Text'),
    '#default_value' => isset($config['page_url_qr_code_alt']) ? $config['page_url_qr_code_alt'] : 'QR code for this page URL',
  );
  $form['page_url_qr_code_width_height'] = array(
    '#type' => 'textfield',
    '#title' => t('QR Code Width & Height'),
    '#description' => t('Width & Height will be same. i.e. 150'),
    '#default_value' => isset($config['page_url_qr_code_width_height']) ? $config['page_url_qr_code_width_height'] : '150',
  );
  $form['page_url_qr_code_api'] = array(
    '#type' => 'radios',
    '#title' => t('Select API'),
    '#description' => t('Select other API where Google is restricted'),
    '#options' => array(
      'google' => 'Google API (recommended)',
      'liantu' => 'Liantu API',
    ),
    '#default_value' => isset($config['page_url_qr_code_api']) ? $config['page_url_qr_code_api'] : 'google',
  );
  return $form;
}