When selecting multiple options in a drop down, only one is passed through to validate/submit handlers.

Comments

bcn’s picture

Issue summary: View changes

Something like the following should allow for multiple value inputs.

diff --git a/sites/all/modules/contrib/selectize/selectize.module b/sites/all/modules/contrib/selectize/selectize.module
index ffc61bf..5a5e050 100644
--- a/sites/all/modules/contrib/selectize/selectize.module
+++ b/sites/all/modules/contrib/selectize/selectize.module
@@ -55,6 +55,11 @@ function selectize_element_validate($element) {
  * @return mixed
  */
 function selectize_element_process($element, &$form_state, $form) {
+  // #multiple select fields need a special #name. @see form_process_select()
+  if ($element['#multiple']) {
+    $element['#attributes']['multiple'] = 'multiple';
+    $element['#attributes']['name'] = $element['#name'] . '[]';
+  }
   if (isset($element['#settings'])) {
     drupal_add_js(array('selectize' => array('settings' => array($element['#id'] => json_encode($element['#settings'])))), array('type' => 'setting'));
   }
focal55’s picture

Worked for me!

kevinquillen’s picture

Assigned: Unassigned » kevinquillen

  • kevinquillen committed 8fb4537 on 7.x-1.x authored by bcn
    Issue #2111499 by kevinquillen, bcn: Multivalue inputs are not preserved
    
kevinquillen’s picture

Ran into this myself when experimenting with Drupal 8 widget support, this works. Great work.

kevinquillen’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

kevinquillen’s picture