@@ -19,36 +19,39 @@ function layout_custom_theme_config_info() {
1919 * Implements hook_form_FORM_ID_alter() for layout_settings_form.
2020 */
2121function layout_custom_theme_form_layout_settings_form_alter(&$form, &$form_state, $form_id) {
22- // Get the name of the layout being modified.
23- $layout_name = $form['name']['#default_value '];
22+ // Get the layout object being modified.
23+ $layout = $form_state['layout '];
2424
25- // Attempt to get the config for this layout .
26- $config = config_get('layout_custom_theme.settings', $layout_name );
25+ // Get the config item if it exists .
26+ $config = config_get('layout_custom_theme.settings', $layout->name );
2727
2828 // Define the form elements.
2929 $form['custom_theme'] = array(
3030 '#title' => t('Custom Theme'),
3131 '#type' => 'item',
32+ '#access' => !$layout->isDefault(),
3233 );
33- $form['custom_theme_enable '] = array(
34+ $form['custom_theme']['enable '] = array(
3435 '#type' => 'checkbox',
3536 '#title' => t('Use custom theme on this layout.'),
3637 '#default_value' => (is_null($config)) ? FALSE : TRUE,
38+ '#access' => !$layout->isDefault(),
3739 );
3840
3941 // Get the options for the themes.
4042 $options = layout_custom_theme_get_themes();
4143
42- $form['custom_theme_theme '] = array(
44+ $form['custom_theme']['theme '] = array(
4345 '#type' => 'select',
4446 '#title' => 'Custom theme',
4547 '#options' => $options,
4648 '#empty_option' => '- Select theme -',
4749 '#default_value' => (is_null($config)) ? '' : $config,
4850 '#states' => array(
49- 'visible' => array(':input[name="custom_theme_enable "]' => array('checked' => TRUE)),
50- 'required' => array(':input[name="custom_theme_enable "]' => array('checked' => TRUE)),
51+ 'visible' => array(':input[name="custom_theme[enable] "]' => array('checked' => TRUE)),
52+ 'required' => array(':input[name="custom_theme[enable] "]' => array('checked' => TRUE)),
5153 ),
54+ '#access' => !$layout->isDefault(),
5255 );
5356 $form['actions']['submit']['#submit'][] = 'layout_custom_theme_form_layout_settings_form_alter_submit';
5457}
@@ -79,20 +82,20 @@ function layout_custom_theme_get_themes() {
7982 * Save the settings.
8083 */
8184function layout_custom_theme_form_layout_settings_form_alter_submit($form, &$form_state) {
82- // Get the name of the layout being modified.
83- $layout_name = $form['name']['#default_value '];
85+ // Get the layout object being modified.
86+ $layout = $form_state['layout '];
8487
8588 // Define the config file.
8689 $config_name = 'layout_custom_theme.settings';
8790
8891 // Check if custom theme is enabled on the form.
89- if ($form_state['values']['custom_theme_enable ']) {
92+ if ($form_state['values']['custom_theme']['enable ']) {
9093 // If so, set a config item for this layout with the value of this theme.
91- config_set($config_name, $layout_name , $form_state['values']['custom_theme_theme ']);
94+ config_set($config_name, $layout->name , $form_state['values']['custom_theme']['theme ']);
9295 }
9396 else {
9497 // If not, delete the config item if it exists.
95- config_clear($config_name, $layout_name );
98+ config_clear($config_name, $layout->name );
9699 }
97100}
98101
0 commit comments