Chris@2
|
1 <?php
|
Chris@2
|
2 use Drupal\Core\Form\FormBase;
|
Chris@2
|
3 use Drupal\Core\Form\FormStateInterface;
|
Chris@2
|
4 /**
|
Chris@2
|
5 * @file
|
Chris@2
|
6 * Validatation for some of the theme settings.
|
Chris@2
|
7 *
|
Chris@2
|
8 * @param $form
|
Chris@2
|
9 * @param FormStateInterface $form_state
|
Chris@2
|
10 */
|
Chris@2
|
11 function mayo_settings_validate($form, FormStateInterface $form_state) {
|
Chris@2
|
12 $values = $form_state->getValues();
|
Chris@2
|
13 $theme_name = \Drupal::theme()->getActiveTheme()->getName();
|
Chris@2
|
14
|
Chris@2
|
15 // Validate our form #state required fields, #states are UI only.
|
Chris@2
|
16 // Bigscreen
|
Chris@2
|
17 if (empty($values['bigscreen_sidebar_first'])) {
|
Chris@2
|
18 form_set_error('bigscreen_sidebar_first', t('Standard Layout <em>First sidebar</em> width is empty - you must enter a value.'));
|
Chris@2
|
19 }
|
Chris@2
|
20 if (empty($values['bigscreen_sidebar_second'])) {
|
Chris@2
|
21 form_set_error('bigscreen_sidebar_second', t('Standard Layout <em>Second sidebar</em> width is empty - you must enter a value.'));
|
Chris@2
|
22 }
|
Chris@2
|
23
|
Chris@2
|
24 // Tablet
|
Chris@2
|
25 if (empty($values['tablet_landscape_sidebar_first'])) {
|
Chris@2
|
26 form_set_error('tablet_landscape_sidebar_first', t('Tablet Landscape <em>First sidebar</em> width is empty - you must enter a value.'));
|
Chris@2
|
27 }
|
Chris@2
|
28 if ($values['tablet_landscape_layout'] === 'three_col_grail' || $values['tablet_landscape_layout'] === 'two_sidebars_left' || $values['tablet_landscape_layout'] === 'two_sidebars_right') {
|
Chris@2
|
29 if (empty($values['tablet_landscape_sidebar_second'])) {
|
Chris@2
|
30 form_set_error('tablet_landscape_sidebar_second', t('Tablet Landscape <em>First sidebar</em> width is empty - you must enter a value. The layout you selected requires values for both sidebars.'));
|
Chris@2
|
31 }
|
Chris@2
|
32 }
|
Chris@2
|
33
|
Chris@2
|
34 // Smalltouch
|
Chris@2
|
35 if ($values['smalltouch_landscape_layout'] === 'one_col_vert') {
|
Chris@2
|
36 if (empty($values['smalltouch_landscape_sidebar_first'])) {
|
Chris@2
|
37 form_set_error('smalltouch_landscape_sidebar_first', t('Smalltouch First Sidebar width is empty - enter a value or choose another layout.'));
|
Chris@2
|
38 }
|
Chris@2
|
39 if (empty($values['smalltouch_landscape_sidebar_second'])) {
|
Chris@2
|
40 form_set_error('smalltouch_landscape_sidebar_second', t('Smalltouch Second Sidebar width is empty - enter a value or choose another layout.'));
|
Chris@2
|
41 }
|
Chris@2
|
42 }
|
Chris@2
|
43 }
|