View difference between Paste ID: qH6PWHmR and U3N5EshH
SHOW: | | - or go back to the newest paste.
1
<?php
2
3
function poetic_toolkit_admin_settings() {
4
5
	$viewport_setting_description = "Enable this to force the viewport to enable viewport 'width=device-width' and set the scale to 1.0. <strong>This MUST be enabled for other settings in this module to function.</strong>";
6
7
	$webapp_setting_description = "Enable this to allow for mobile devices to save the page as a bookmark and load into a webapp wrapper (for iOS and Android).";
8
9
10
	$form['poetic_toolkit_mobile_viewport_setting'] = array(
11
		'#type' => 'checkbox',
12
		'#title' => t('Enable Mobile Viewport'),
13
		'#description' => t($viewport_setting_description),
14
		'#default_value' => variable_get('poetic_toolkit_mobile_viewport_setting', TRUE),
15
	);
16
17
	$form['poetic_toolkit_enable_webapp_setting'] = array(
18
		'#type' => 'checkbox',
19
		'#title' => t('Enable Mobile Web App'),
20
		'#description' => t($webapp_setting_description),
21
		'#default_value' => variable_get('poetic_toolkit_enable_webapp_setting', FALSE),
22
		'#states' => array('visible' => array(':input[name="poetic_toolkit_mobile_viewport_setting"]' => array('checked' => TRUE),),),
23
	);
24
25-
  array_unshift($form['#submit'], 'poetic_toolkit_admin_submit');
25+
        array_unshift($form['#submit'], 'poetic_toolkit_admin_submit');
26
        
27
        dmp($form); // check the structure of the form here
28
29
	return system_settings_form($form);
30
}
31
32
function poetic_toolkit_admin_submit($form, &$form_state) {
33
  // check if field A is checked
34
  if(!$form_state['values']['poetic_toolkit_mobile_viewport_setting']) {
35
    // if it is not then set field B value to 0
36
    $form_state['values']['poetic_toolkit_enable_webapp_setting'] = 0;
37
38
  }
39
40
  dpm($form_state['values']); // check the values have been updated correctly here
41
42
}