diff --git a/commerce_popular_products.module b/commerce_popular_products.module index 0efcb26fdea68d45246b70af871515796dd973f0..d3af44e04453aac8fe0ae314efc45054df265aa8 100644 --- a/commerce_popular_products.module +++ b/commerce_popular_products.module @@ -196,14 +196,17 @@ function commerce_popular_products_settings_form($form, &$form_state) { $products = variable_get('commerce_popular_products_products'); $title = check_plain(variable_get('commerce_popular_products_title', 'Popular Products This Month')); $product_types = commerce_popular_products_get_product_types(); - $form['block_title'] = array( + $form['preamble'] = array( + '#markup' => '

' . t('Here you can define which product types are ranked for popularity & the period over which they are ranked.') . '

', + ); + $form['commerce_popular_products_title'] = array( '#type' => 'textfield', '#title' => t('Block title.'), '#description' => t('The title of the "popular products" block as shown to users.'), '#default_value' => $title, ); if (isset($product_types)) { - $form['product_types'] = array( + $form['commerce_popular_products_products'] = array( '#type' => 'checkboxes', '#title' => t('Product Types.'), '#description' => t('Product nodes to include in the popularity check.'), @@ -222,15 +225,15 @@ function commerce_popular_products_settings_form($form, &$form_state) { foreach ($product_types as $type) { $options[$type] = $type; } - $form['product_types']['#options'] = $options; + $form['commerce_popular_products_products']['#options'] = $options; if (empty($products)) { $products = array(); foreach ($product_types as $type) { $products[$type] = 0; } } - $form['product_types']['#default_value'] = $products; - $form['time_period'] = array( + $form['commerce_popular_products_products']['#default_value'] = $products; + $form['commerce_popular_products_time'] = array( '#type' => 'radios', '#title' => t('Timeframe.'), '#description' => t('The timeframe within which to calculate popularity.'), @@ -242,7 +245,7 @@ function commerce_popular_products_settings_form($form, &$form_state) { ), '#default_value' => $time, ); - $form['number_display'] = array( + $form['commerce_popular_products_number'] = array( '#type' => 'select', '#title' => t('Display.'), '#description' => t('How may ranked popular products would you like included in the display?'), @@ -255,13 +258,14 @@ function commerce_popular_products_settings_form($form, &$form_state) { ), '#default_value' => $number, ); - $form['submit'] = array('#type' => 'submit', '#value' => t('Save'));; - return $form; + //$form['submit'] = array('#type' => 'submit', '#value' => t('Save')); + + return system_settings_form($form); } /** * Custom submit handler for settings form: saves values to Variable table. - */ + function commerce_popular_products_settings_form_submit($form, &$form_state) { $values = $form_state['values']; $products = $values['product_types']; @@ -273,7 +277,7 @@ function commerce_popular_products_settings_form_submit($form, &$form_state) { variable_set('commerce_popular_products_number', $number); variable_set('commerce_popular_products_products', $products); drupal_set_message(t('Your settings have been saved.')); -} +} */ /** * A simple query to return all the Commerce product types in the database.