You are here

public function TrumbaBlockBase::blockForm in Trumba 2.x

Same name and namespace in other branches
  1. 8 src/Plugin/Block/TrumbaBlockBase.php \Drupal\trumba\Plugin\Block\TrumbaBlockBase::blockForm()

Overrides BlockPluginTrait::blockForm

3 calls to TrumbaBlockBase::blockForm()
TrumbaMainCalendarSpudBlock::blockForm in src/Plugin/Block/TrumbaMainCalendarSpudBlock.php
TrumbaOpenSpudBlock::blockForm in src/Plugin/Block/TrumbaOpenSpudBlock.php
TrumbaPromoControlSpudBlock::blockForm in src/Plugin/Block/TrumbaPromoControlSpudBlock.php
3 methods override TrumbaBlockBase::blockForm()
TrumbaMainCalendarSpudBlock::blockForm in src/Plugin/Block/TrumbaMainCalendarSpudBlock.php
TrumbaOpenSpudBlock::blockForm in src/Plugin/Block/TrumbaOpenSpudBlock.php
TrumbaPromoControlSpudBlock::blockForm in src/Plugin/Block/TrumbaPromoControlSpudBlock.php

File

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

Class

TrumbaBlockBase
Defines a base block implementation that Trumba blocks plugins will extend.

Namespace

Drupal\trumba\Plugin\Block

Code

public function blockForm($form, FormStateInterface $form_state) {
  $form['trumba_web_name'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Web Name'),
    '#description' => $this
      ->t('This is the unique identifier for your calendar account on Trumba.'),
    '#default_value' => isset($this->configuration['trumba_web_name']) ? $this->configuration['trumba_web_name'] : $this->defaultTrumbaWebName,
    '#maxlength' => 255,
    '#size' => 64,
    '#weight' => '1',
    '#required' => TRUE,
  ];
  $form['trumba_same_page'] = [
    '#type' => 'radios',
    '#title' => $this
      ->t('Is this block on the same page as the Main Calendar?'),
    '#default_value' => isset($this->configuration['trumba_same_page']) ? $this->configuration['trumba_same_page'] : 0,
    '#options' => array(
      0 => $this
        ->t('Yes'),
      1 => $this
        ->t('No'),
    ),
  ];
  $form['trumba_spud_url'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Calendar URL'),
    '#description' => $this
      ->t('Enter the internal path (e.g.: "/node/1") or the full URL for where this calendar will be placed (e.g.: "https://www.yoursite.com/calendar").'),
    '#default_value' => isset($this->configuration['trumba_spud_url']) && !empty($this->configuration['trumba_spud_url']) ? $this
      ->convertUriToRelativePathOrUrl($this->configuration['trumba_spud_url']) : '',
    '#maxlength' => 255,
    '#size' => 64,
    '#weight' => '2',
    '#states' => [
      'invisible' => [
        ':input[name="settings[trumba_same_page]"]' => [
          'value' => 0,
        ],
      ],
      'required' => [
        ':input[name="settings[trumba_same_page]"]' => [
          'value' => 1,
        ],
      ],
    ],
  ];
  return $form;
}