From c664210c45a1db59cb6c7258e81bd4757da39149 Mon Sep 17 00:00:00 2001 From: Jon Skulski Date: Wed, 15 Jun 2011 12:51:17 -0700 Subject: [PATCH 1/5] Fixing .info for core --- betterselect.info | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/betterselect.info b/betterselect.info index 27e8da6..89f8964 100644 --- a/betterselect.info +++ b/betterselect.info @@ -1,3 +1,3 @@ name = Better Select description = Use stylized checkboxes instead of the default multiple select HTML element in forms. -core = 6.x +core = 7.x -- 1.7.0.4 From edc0e098ef1e7682bb7af1a721a47987363a3b8b Mon Sep 17 00:00:00 2001 From: Jon Skulski Date: Thu, 16 Jun 2011 17:25:15 -0700 Subject: [PATCH 2/5] Fitting betterselect proformapi elements to drupal7 --- betterselect.module | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/betterselect.module b/betterselect.module index 954387b..4f602f2 100644 --- a/betterselect.module +++ b/betterselect.module @@ -69,11 +69,11 @@ function betterselect_admin_settings() { } /** - * Implementation of hook_elements(). + * Implementation of hook_element_info(). */ -function betterselect_elements() { +function betterselect_element_info() { $type = array(); - $type['select']['#process'] = array('betterselect_process'); + $type['select']['#process'] = array('betterselect_process_element'); return $type; } @@ -81,7 +81,7 @@ function betterselect_elements() { /** * Form process callback; translates multiselect fields into checkboxes. */ -function betterselect_process($element, $edit, $form_state, $complete_form) { +function betterselect_process_element($element, &$form_state, $complete_form) { if (isset($element['#multiple']) && $element['#multiple'] == TRUE && !(variable_get('betterselect_node_form_only', FALSE) == TRUE && $complete_form['#id'] != 'node-form')) { // If we're dealing with taxonomy, fix the option titles. @@ -107,7 +107,7 @@ function betterselect_process($element, $edit, $form_state, $complete_form) { } } - // The default value should be an array, if it isn't expand_checkboxes() + // The default value should be an array, if it isn't form_process_checkboxes() // will make it one. if (isset($element['#default_value']) && is_array($element['#default_value']) && count($element['#default_value'])) { // Fix the value arrays; checkboxes are the exact inverse of multiselect, @@ -129,7 +129,7 @@ function betterselect_process($element, $edit, $form_state, $complete_form) { // Switch display to checkboxes instead. $element['#type'] = 'checkboxes'; unset($element['#theme']); - $element = expand_checkboxes($element); + $element = form_process_checkboxes($element); // Hide the silly "None" option. (assumes array element with a blank key is the "None" option) if (!$element['#required'] && is_array($element[''])) { -- 1.7.0.4 From 87007d057d2157e2fb383791ef372a829127f830 Mon Sep 17 00:00:00 2001 From: Jon Skulski Date: Thu, 16 Jun 2011 17:27:42 -0700 Subject: [PATCH 3/5] Better php karma, avoid notices --- betterselect.module | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/betterselect.module b/betterselect.module index 4f602f2..99d4077 100644 --- a/betterselect.module +++ b/betterselect.module @@ -85,7 +85,7 @@ function betterselect_process_element($element, &$form_state, $complete_form) { if (isset($element['#multiple']) && $element['#multiple'] == TRUE && !(variable_get('betterselect_node_form_only', FALSE) == TRUE && $complete_form['#id'] != 'node-form')) { // If we're dealing with taxonomy, fix the option titles. - if (is_object($element['#options'][0])) { + if (isset($element['#options'][0]) && is_object($element['#options'][0])) { // Build new array of options in format that theme_checkboxes expects. $options = array(); $defaults = array(); @@ -132,7 +132,7 @@ function betterselect_process_element($element, &$form_state, $complete_form) { $element = form_process_checkboxes($element); // Hide the silly "None" option. (assumes array element with a blank key is the "None" option) - if (!$element['#required'] && is_array($element[''])) { + if (isset($elemnet['#required']) && !$element['#required'] && is_array($element[''])) { $element['']['#prefix'] = '
'; $element['']['#suffix'] = '
'; } -- 1.7.0.4 From e70516064fee2a9dfd2a632900bd1d54cad2161f Mon Sep 17 00:00:00 2001 From: Jon Skulski Date: Thu, 16 Jun 2011 17:33:17 -0700 Subject: [PATCH 4/5] Drupal 7 expects #attributes as an array. --- betterselect.module | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/betterselect.module b/betterselect.module index 99d4077..92a25a3 100644 --- a/betterselect.module +++ b/betterselect.module @@ -124,7 +124,7 @@ function betterselect_process_element($element, &$form_state, $complete_form) { // Place options in a scrollable or non-scrollable div $div_class = variable_get('betterselect_scroll', FALSE) ? 'form-checkboxes-scroll' : 'form-checkboxes-noscroll'; - $element['#attributes'] = array('class' => $div_class); + $element['#attributes'] = array('class' => array($div_class)); // Switch display to checkboxes instead. $element['#type'] = 'checkboxes'; -- 1.7.0.4 From e9bee36a6e69b6772cde7dfe5d03cb31124b943f Mon Sep 17 00:00:00 2001 From: Jon Skulski Date: Fri, 17 Jun 2011 14:25:34 -0700 Subject: [PATCH 5/5] Fitting better select into Drupal 7's admin scheme --- betterselect.module | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/betterselect.module b/betterselect.module index 92a25a3..2933961 100644 --- a/betterselect.module +++ b/betterselect.module @@ -12,8 +12,8 @@ */ function betterselect_menu() { $items = array(); - $items['admin/settings/betterselect'] = array( - 'title' => t('Better select'), + $items['admin/config/betterselect'] = array( + 'title' => t('Better Select'), 'description' => t('Configure better select settings.'), 'page callback' => 'drupal_get_form', 'page arguments' => array('betterselect_admin_settings'), -- 1.7.0.4