You are here

public function BlazyAdminExtended::openingForm in Blazy 8

Same name and namespace in other branches
  1. 8.2 src/Dejavu/BlazyAdminExtended.php \Drupal\blazy\Dejavu\BlazyAdminExtended::openingForm()

Returns shared form elements across field formatter and Views.

Overrides BlazyAdminBase::openingForm

File

src/Dejavu/BlazyAdminExtended.php, line 16

Class

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

Namespace

Drupal\blazy\Dejavu

Code

public function openingForm(array &$form, $definition = []) {
  $namespace = isset($definition['namespace']) ? $definition['namespace'] : 'blazy';
  if (!empty($definition['vanilla'])) {
    $form['vanilla'] = [
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Vanilla @namespace', [
        '@namespace' => $namespace,
      ]),
      '#description' => $this
        ->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',
        ],
      ],
      '#wrapper_attributes' => [
        'class' => [
          'form-item--full',
          'form-item--tooltip-bottom',
        ],
      ],
    ];
  }
  if (!empty($definition['optionsets']) && $namespace != 'blazy') {
    $form['optionset'] = [
      '#type' => 'select',
      '#title' => $this
        ->t('Optionset'),
      '#options' => $definition['optionsets'],
      '#enforced' => TRUE,
      '#description' => $this
        ->t('Enable the optionset UI module to manage the optionsets.'),
      '#weight' => -108,
    ];
  }
  parent::openingForm($form, $definition);
}