public function BlazyAdminBase::gridForm in Blazy 8.2
Same name and namespace in other branches
- 8 src/Form/BlazyAdminBase.php \Drupal\blazy\Form\BlazyAdminBase::gridForm()
- 7 src/Form/BlazyAdminBase.php \Drupal\blazy\Form\BlazyAdminBase::gridForm()
Returns re-usable grid elements across field formatter and Views.
1 call to BlazyAdminBase::gridForm()
- BlazyAdminFormatter::buildSettingsForm in src/
Form/ BlazyAdminFormatter.php - Defines re-usable form elements.
File
- src/
Form/ BlazyAdminBase.php, line 221
Class
- BlazyAdminBase
- A base for blazy admin integration to have re-usable methods in one place.
Namespace
Drupal\blazy\FormCode
public function gridForm(array &$form, $definition = []) {
$range = range(1, 12);
$grid_options = array_combine($range, $range);
$required = !empty($definition['grid_required']);
$header = $this
->t('Group individual items as block grid<small>Depends on the <strong>Display style</strong>.</small>');
$form['grid_header'] = [
'#type' => 'markup',
'#markup' => '<h3 class="form__title form__title--grid">' . $header . '</h3>',
'#access' => !$required,
];
if ($required) {
$description = $this
->t('The amount of block grid columns for large monitors 64.063em.');
}
else {
$description = $this
->t('Select <strong>- None -</strong> first if trouble with changing form states. The amount of block grid columns for large monitors 64.063em+. <br /><strong>Requires</strong>:<ol><li>Visible items,</li><li>Skin Grid for starter,</li><li>A reasonable amount of contents.</li></ol>Unless required, leave empty to DIY, or to not build grids.');
}
$form['grid'] = [
'#type' => 'select',
'#title' => $this
->t('Grid large'),
'#options' => $grid_options,
'#description' => $description,
'#enforced' => TRUE,
'#required' => $required,
];
$form['grid_medium'] = [
'#type' => 'select',
'#title' => $this
->t('Grid medium'),
'#options' => $grid_options,
'#description' => $this
->t('The amount of block grid columns for medium devices 40.063em - 64em.'),
];
$form['grid_small'] = [
'#type' => 'select',
'#title' => $this
->t('Grid small'),
'#options' => $grid_options,
'#description' => $this
->t('The amount of block grid columns for small devices 0 - 40em. Specific to <strong>CSS3 Columns</strong>, only 1 - 2 column is respected due to small real estate at smallest device.'),
];
$form['visible_items'] = [
'#type' => 'select',
'#title' => $this
->t('Visible items'),
'#options' => array_combine(range(1, 32), range(1, 32)),
'#description' => $this
->t('How many items per display at a time.'),
];
$form['preserve_keys'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Preserve keys'),
'#description' => $this
->t('If checked, keys will be preserved. Default is FALSE which will reindex the grid chunk numerically.'),
'#access' => FALSE,
];
$grids = [
'grid_header',
'grid_medium',
'grid_small',
'visible_items',
'preserve_keys',
];
foreach ($grids as $key) {
$form[$key]['#enforced'] = TRUE;
$form[$key]['#states'] = [
'visible' => [
'select[name$="[grid]"]' => [
'!value' => '',
],
],
];
}
}