You are here

public function BlazyAdminExtended::openingForm in Blazy 7

Returns shared form elements across field formatter and Views.

Overrides BlazyAdminBase::openingForm

File

src/Form/BlazyAdminExtended.php, line 13

Class

BlazyAdminExtended
Provides re-usable admin functions, or form elements.

Namespace

Drupal\blazy\Form

Code

public function openingForm(array &$form, &$definition = []) {
  $namespace = isset($definition['namespace']) ? $definition['namespace'] : 'blazy';
  if (!empty($definition['vanilla'])) {
    $form['vanilla'] = [
      '#type' => 'checkbox',
      '#title' => t('Vanilla @namespace', [
        '@namespace' => $namespace,
      ]),
      '#description' => t('<strong>Check</strong>:<ul><li>To render individual item as is as without extra logic.</li><li>To disable 99% @module features, and most of the mentioned options here, such as layouts, et al.</li><li>When the @module features can not satisfy the need.</li><li>Things may be broken! You are on your own.</li></ul><strong>Uncheck</strong>:<ul><li>To get consistent markups and its advanced features -- relevant for the provided options as @module needs to know what to style/work with.</li></ul>', [
        '@module' => $namespace,
      ]),
      '#weight' => -109,
      '#enforced' => TRUE,
      '#attributes' => [
        'class' => [
          'form-checkbox--vanilla',
        ],
        'data-blazy-tooltip' => 'wide',
        'data-blazy-tooltip-direction' => 'bottom',
      ],
    ];
  }
  if (!empty($definition['optionsets']) && $namespace != 'blazy') {
    $form['optionset'] = [
      '#type' => 'select',
      '#title' => t('Optionset'),
      '#options' => $definition['optionsets'],
      '#enforced' => TRUE,
      '#description' => t('Enable the optionset UI module to manage the optionsets.'),
      '#weight' => -108,
    ];
  }
  parent::openingForm($form, $definition);
}