function gin_lb_form_alter in Gin Layout Builder 1.0.x
Implements hook_form_alter().
File
- ./
gin_lb.module, line 298 - Provides hooks for gin_lb module.
Code
function gin_lb_form_alter(&$form, FormStateInterface $form_state, $form_id) {
if (gin_lb_is_valid_theme() === FALSE) {
return;
}
if (gin_lb_is_layout_builder_form_id($form_id, $form)) {
$form['#after_build'][] = 'gin_lb_after_build';
$form['#gin_lb_form'] = TRUE;
$form['#attributes']['class'][] = 'glb-form';
}
if (strpos($form_id, 'layout_builder_form') !== FALSE) {
$form['advanced']['#type'] = 'container';
$form['actions']['preview_toggle']['toggle_content_preview']['#title'] = t('Preview');
$form['actions']['configure'] = [
'#type' => 'markup',
'#markup' => '<div class="glb-configure"></div>',
'#weight' => -100,
];
$weight = $form["actions"]["preview_toggle"]["#weight"] ?? 0;
$form['actions']['preview_regions'] = [
'#type' => 'checkbox',
'#title' => t('Regions'),
'#weight' => $weight + 1,
'#id' => 'glb-preview-regions',
];
}
if (in_array($form_id, [
'layout_builder_update_block',
'layout_builder_add_block',
'layout_builder_configure_section',
'layout_builder_remove_section',
'layout_builder_remove_block',
])) {
$form['#attributes']['class'][] = 'canvas-form';
if (isset($form['settings'])) {
$form['settings']['#type'] = 'container';
$form['settings']['#attributes']['class'][] = 'canvas-form__settings';
}
if (isset($form['layout_settings'])) {
$form['layout_settings']['#type'] = 'container';
$form['layout_settings']['#attributes']['class'][] = 'canvas-form__settings';
}
if (in_array($form_id, [
'layout_builder_remove_block',
'layout_builder_remove_section',
])) {
$form['description']['#type'] = 'container';
$form['description']['#attributes']['class'][] = 'canvas-form__settings';
}
$form['actions']['#type'] = 'container';
$form['actions']['#attributes']['class'][] = 'canvas-form__actions';
}
}