summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwebchick <webchick@24967.no-reply.drupal.org>2011-12-10 23:53:03 -0600
committerwebchick <webchick@24967.no-reply.drupal.org>2011-12-10 23:53:03 -0600
commita2588037892138ab71f6249816fd3c909fa2ee3d (patch)
treeeb49acf96ce9d222c1d0f3c73caa0e1fdd2f82b4
parentad0423550cc27a7e2b8e1388a74c99348b5dc486 (diff)
downloadbrdo-a2588037892138ab71f6249816fd3c909fa2ee3d.tar.gz
brdo-a2588037892138ab71f6249816fd3c909fa2ee3d.tar.bz2
Issue #1346760 by xjm: Fixed Drag and drop needs a scalable weight select element.
-rw-r--r--includes/form.inc26
-rw-r--r--modules/system/system.module7
2 files changed, 27 insertions, 6 deletions
diff --git a/includes/form.inc b/includes/form.inc
index e0bc9cba0..52eb10bc9 100644
--- a/includes/form.inc
+++ b/includes/form.inc
@@ -3786,13 +3786,27 @@ function theme_password($variables) {
* Expand weight elements into selects.
*/
function form_process_weight($element) {
- for ($n = (-1 * $element['#delta']); $n <= $element['#delta']; $n++) {
- $weights[$n] = $n;
- }
- $element['#options'] = $weights;
- $element['#type'] = 'select';
$element['#is_weight'] = TRUE;
- $element += element_info('select');
+
+ // If the number of options is small enough, use a select field.
+ $max_elements = variable_get('drupal_weight_select_max', DRUPAL_WEIGHT_SELECT_MAX);
+ if ($element['#delta'] <= $max_elements) {
+ $element['#type'] = 'select';
+ for ($n = (-1 * $element['#delta']); $n <= $element['#delta']; $n++) {
+ $weights[$n] = $n;
+ }
+ $element['#options'] = $weights;
+ $element += element_info('select');
+ }
+ // Otherwise, use a text field.
+ else {
+ $element['#type'] = 'textfield';
+ // Use a field big enough to fit most weights.
+ $element['#size'] = 10;
+ $element['#element_validate'] = array('element_validate_integer');
+ $element += element_info('textfield');
+ }
+
return $element;
}
diff --git a/modules/system/system.module b/modules/system/system.module
index d0a542efb..46ec87db1 100644
--- a/modules/system/system.module
+++ b/modules/system/system.module
@@ -46,6 +46,13 @@ define('DRUPAL_OPTIONAL', 1);
define('DRUPAL_REQUIRED', 2);
/**
+ * Maximum number of values in a weight select element.
+ *
+ * If the number of values is over the maximum, a text field is used instead.
+ */
+define('DRUPAL_WEIGHT_SELECT_MAX', 100);
+
+/**
* Return only visible regions.
*
* @see system_region_list()