1

The intention here is to parse out the two integers on either side of the dash, and save them as separate defaults. The problem I'm running into is nothing will actually save when I submit the theme-settings form, it just keeps resetting to the defaults and not the new value selected prior to saving.

dpm'ing the output variables from the grid array returns the exact same results as dpm'ing the theme-get-setting return if I do it using the method at the bottom of the post.. so i am at a loss on why this doesn't save new values when the theme-settings form is submitted.

Here is an example of the setup:

.info values

settings[user_first_wp] = '6-1'

theme-settings.tpl.php:

$grid = array();
list($grid['user_first_width'], $grid['user_first_pos']) = explode('-', theme_get_setting('user_first_wp'));

// User group first position.
$form['gaia_settings']['layout']['user']['1'] = array(
  '#type'          => 'select',
  '#title'         => t('Position'),
  '#attributes'    => array('class' => array('col-position')),
  '#default_value' => $grid['user_first_pos'],
  '#options'       => $pos_options,
);

// User group first width.
$form['gaia_settings']['layout']['user']['1'] = array(
  '#type'          => 'select',
  '#title'         => t('User 1 Width'),
  '#attributes'    => array('class' => array('col-width')),
  '#default_value' => $grid['user_first_width'],
  '#options'       => $width_options,
);

Doing it this way (below), does actually work, but I'd much rather keep multiple values in the same theme-setting default.

.info

settings[user_first_width] = '6'
settings[user_first_pos] = '1'

theme-settings.tpl.php

// User first position.
$form['gaia_settings']['layout']['user']['1'] = array(
  '#type'          => 'select',
  '#title'         => t('Position'),
  '#attributes'    => array('class' => array('col-pos')),
  '#default_value' => theme_get_setting('user_first_pos'),
  '#options'       => $pos_options,
);

// User first width.
$form['gaia_settings']['layout']['user']['1'] = array(
  '#type'          => 'select',
  '#title'         => t('User 1 width'),
  '#attributes'    => array('class' => array('col-width')),
  '#default_value' => theme_get_setting('user_first_width'),
  '#options'       => $width_options,
);
2
  • Tried using substr() but no go pastebin.ca/2178826
    – krisbulman
    Commented Aug 10, 2012 at 0:57
  • Your code does not give enough information. (Is it inside a specific function, for example _form_system_theme_settings_alter()?) What is apparent in the code is that you overwrite the first $form['gaia_settings']['layout']['user']['1'] when setting it to something else the second time. Maybe you need to use 0 and 1 to distinguish the elements: $form['gaia_settings']['layout']['user']['0'] and $form['gaia_settings']['layout']['user']['1'].
    – iva2k
    Commented Jan 9, 2013 at 20:45

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.