SHARE
TWEET

new toolkit

a guest Apr 3rd, 2014 42 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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');
  26.  
  27.         return system_settings_form($form);
  28. }
  29.  
  30. function poetic_toolkit_admin_submit($form, &$form_state) {
  31.   // check if field A is checked
  32.   if(!$form_state['values']['poetic_toolkit_mobile_viewport_setting']) {
  33.     // if it is not then set field B value to 0
  34.     $form_state['values']['poetic_toolkit_enable_webapp_setting'] = 0;
  35.  
  36.   }
  37. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top