From 53462da9b78ae0241e0629b89c1bfca069d5b074 Mon Sep 17 00:00:00 2001 From: Reuben Nantogmah Date: Sun, 28 Aug 2011 19:22:43 -0400 Subject: [PATCH] Issue: http://drupal.org/node/445268 - Added weight option to configuration form --- terms_of_use.admin.inc | 18 +++++++++++++++++- terms_of_use.module | 4 ++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/terms_of_use.admin.inc b/terms_of_use.admin.inc index 59ca703..d7c66fd 100644 --- a/terms_of_use.admin.inc +++ b/terms_of_use.admin.inc @@ -50,6 +50,13 @@ function terms_of_use_admin_settings() { '#default_value' => variable_get('terms_of_use_checkbox_label', t('I agree with these terms')), '#description' => t('Type here something like "I agree with these terms." or "I CERTIFY THAT I AM OVER THE AGE OF 18 YEARS OLD.", without quotes. You can use the token @link to insert a link to the Terms in this label. For example, the label can be: "I agree with the @link.", without quotes. You may want to link to the Terms if you prefer not to show the full text of the Terms in the registration form. If you use the token, the Terms will not be shown.'), ); + + $form['terms_of_use_form']['terms_of_use_weight'] = array( + '#type' => 'textfield', + '#title' => t('Weight'), + '#default_value' => variable_get('terms_of_use_fieldset_weight', 10), + '#description' => t('The weight controls the order or position of the terms of use fieldset on the registration page'), + ); return system_settings_form($form); } @@ -94,7 +101,16 @@ function terms_of_use_admin_settings_validate($form, &$form_state) { } else { form_set_error('terms_of_use_node_title', t('You must specify a node title.')); - } + } + if (!empty($form_state['values']['terms_of_use_weight'])) { + $weight = $form_state['values']['terms_of_use_weight'] ; + if(!is_numeric($weight)){ + form_set_error('terms_of_use_weight', t('The weight must be an integer')); + } + else { + variable_set('terms_of_use_fieldset_weight', $weight); + } + } } /** diff --git a/terms_of_use.module b/terms_of_use.module index 2437e3d..74212eb 100644 --- a/terms_of_use.module +++ b/terms_of_use.module @@ -56,7 +56,7 @@ function terms_of_use_form_user_register_form_alter(&$form, $form_state) { $form['terms_of_use'] = array( '#type' => 'fieldset', '#title' => $fieldset_name, - '#weight' => 10, + '#weight' => variable_get('terms_of_use_fieldset_weight', 10), ); $show_terms = TRUE; @@ -144,4 +144,4 @@ function theme_terms_of_use($variables) { $output .= ''; return $output; -} \ No newline at end of file +} -- 1.7.1.1