You are here

public function PhoneDonationBlock::blockForm in Commerce Donate 8

Creates fields for Phone Donation block form.

Overrides BlockPluginTrait::blockForm

File

src/Plugin/Block/PhoneDonationBlock.php, line 23

Class

PhoneDonationBlock
Provides a Phone to Donate block.

Namespace

Drupal\commerce_donate\Plugin\Block

Code

public function blockForm($form, FormStateInterface $form_state) {
  $form = parent::blockForm($form, $form_state);
  $config = $this
    ->getConfiguration();
  $form['intro'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Intro text'),
    '#description' => $this
      ->t('Use this to introduce the donation telephone numbers.'),
    '#default_value' => isset($config['intro']) ? $config['intro'] : t('You can also donate over the phone by calling'),
  ];
  $form['main_number'] = [
    '#type' => 'details',
    '#title' => t('Main donation number'),
    '#open' => TRUE,
  ];
  $form['main_number']['label'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Number label'),
    '#description' => $this
      ->t('Text to prefix the main donation number, for example: Free Call'),
    '#default_value' => isset($config['main_number_label']) ? $config['main_number_label'] : t('Free call'),
  ];
  $form['main_number']['number'] = [
    '#type' => 'number',
    '#title' => $this
      ->t('Main Number'),
    '#description' => $this
      ->t('Main telephone number.'),
    '#default_value' => isset($config['main_number']) ? $config['main_number'] : '',
  ];
  $form['intl_number'] = [
    '#type' => 'details',
    '#title' => t('International donation number'),
  ];
  $form['intl_number']['label'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('International number label'),
    '#description' => $this
      ->t('Prefix text for international number'),
    '#default_value' => isset($config['intl_number_label']) ? $config['intl_number_label'] : '',
  ];
  $form['intl_number']['number'] = [
    '#type' => 'number',
    '#title' => $this
      ->t('International Number'),
    '#description' => $this
      ->t('International telephone number with country prefix.'),
    '#default_value' => isset($config['intl_number']) ? $config['intl_number'] : '',
  ];
  return $form;
}