I'm trying to set some theme settings, and I can't figure out how to have my settings get their default value, which should be obviously the currently set value.

Here's an example:

$form['navbar_layout'] = array(
    '#type'          => 'radios',
    '#options'       => array(
        0 => 'Logo left, Menu right',
        1 => 'Logo right, Menu left',
    '#default_value' => theme_get_setting('navbar_layout'),
    '#title'         => t('Navbar\'s Layout'),
    '#description'   => t("Choose the layout of the navbar."),

Each time I'll access the theme settings page, no box will be checked, despite the fact theme_get_setting() correctly returns the right value.

  • Does the function return a 0 or 1? – Kevin Mar 17 '17 at 13:39

I think it will only execute if you save the theme settings page. If you want to have the default work upon theme activation you have to have your setting in your theme's .info file. I could be wrong.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.