summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnthony Lindsay2014-10-19 09:43:06 (GMT)
committerAnthony Lindsay2014-10-19 09:43:06 (GMT)
commite8b10c40449bb525722c2081e14477d1ebc1021e (patch)
treea4e6a8475c367e01c4646386815a955b6afa190d
parentfdc6874d979f12085ff24e6f34bf7c55204cc6c2 (diff)
Got rid of redundant submit function in favour of system_settings_form
-rw-r--r--commerce_popular_products.module24
1 files changed, 14 insertions, 10 deletions
diff --git a/commerce_popular_products.module b/commerce_popular_products.module
index 0efcb26..d3af44e 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' => '<p>' . t('Here you can define which product types are ranked for popularity & the period over which they are ranked.') . '</p>',
+ );
+ $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.