You are here

public function CountBlock::blockForm in Basic cart 8.4

Same name and namespace in other branches
  1. 8.6 src/Plugin/Block/CountBlock.php \Drupal\basic_cart\Plugin\Block\CountBlock::blockForm()
  2. 8.2 src/Plugin/Block/CountBlock.php \Drupal\basic_cart\Plugin\Block\CountBlock::blockForm()
  3. 8.3 src/Plugin/Block/CountBlock.php \Drupal\basic_cart\Plugin\Block\CountBlock::blockForm()
  4. 8.5 src/Plugin/Block/CountBlock.php \Drupal\basic_cart\Plugin\Block\CountBlock::blockForm()

Overrides BlockPluginTrait::blockForm

File

src/Plugin/Block/CountBlock.php, line 62

Class

CountBlock
Provides a 'Basic Cart Count' block.

Namespace

Drupal\basic_cart\Plugin\Block

Code

public function blockForm($form, FormStateInterface $form_state) {
  $form = parent::blockForm($form, $form_state);
  $config = $this
    ->getConfiguration();
  $form['size'] = array(
    '#type' => 'select',
    '#options' => [
      '32x26' => '32x26',
      '48x39' => '48x39',
      '128x105' => '128x105',
      '64x52' => '64x52',
    ],
    '#title' => $this
      ->t('Cart Icon Size'),
    '#description' => $this
      ->t('Cart icon size'),
    '#default_value' => isset($config['size']) ? $config['size'] : '48x29',
  );
  $form['float'] = array(
    '#type' => 'select',
    '#options' => [
      'none' => 'none',
      'right' => 'right',
      'left' => 'left',
    ],
    '#title' => $this
      ->t('Float'),
    '#description' => $this
      ->t('Cart icon floated to right or left'),
    '#default_value' => isset($config['float']) ? $config['float'] : '',
  );
  $form['top'] = array(
    '#type' => 'textfield',
    '#title' => $this
      ->t('Top'),
    '#description' => $this
      ->t('Top positon value in pixel'),
    '#default_value' => isset($config['top']) ? $config['top'] : '',
    '#size' => 3,
  );
  $form['bottom'] = array(
    '#type' => 'textfield',
    '#title' => $this
      ->t('Bottom'),
    '#description' => $this
      ->t('Bottom positon value in pixel'),
    '#default_value' => isset($config['bottom']) ? $config['bottom'] : '',
    '#size' => 3,
  );
  $form['left'] = array(
    '#type' => 'textfield',
    '#title' => $this
      ->t('Left'),
    '#description' => $this
      ->t('Left positon value in pixel'),
    '#default_value' => isset($config['left']) ? $config['left'] : '',
    '#size' => 3,
  );
  $form['right'] = array(
    '#type' => 'textfield',
    '#title' => $this
      ->t('Right'),
    '#description' => $this
      ->t('Right positon value in pixel'),
    '#default_value' => isset($config['right']) ? $config['right'] : '',
    '#size' => 3,
  );
  return $form;
}