When Multiselect is used in Form API, Widget does not work. I am facing two issues:
1. Add/Remove button does not work, even button does not get render properly.
2. Form submission gives error if no item is selected in 'Selected Box' of Multiselect Form, even if attribute [#required] is set to FALSE
How to easily reproduce this issue on Drupal 7.19, PHP 5.3.x
1. download and enable multiselect module long with its FAPI Example module.
2. open form url '[ur_drupal_site]'/multiselect_fapi_example in Firefox browser.
is there any workaround available?
if not, I can work on rolling a patch.
---------------Form------------------------
$form['multiselector'] = array(
'#type' => 'multiselect',
'#title' => t('Here is the multiselect'),
'#options' => array(
'title' => t('Titles only'),
'teaser' => t('Titles plus teaser'),
'fulltext' => t('Full text'),
'1' => t('Option 1'),
'2' => t('Option 2'),
'3' => t('Option 3'),
'4' => t('Option 4'),
'5' => t('Option 5'),
'6' => t('Option 6'),
'7' => t('Option 7'),
'8' => t('Option 8'),
'9' => t('Option 9'),
'10' => t('Option 10'),
'11' => t('Option 11'),
'12' => t('Option 12'),
),
'#default_value' => _multiselect_fapi_example_options(),
'#multiple' => TRUE,
'#size' => 15,
'#required' => FALSE
);
$form = system_settings_form($form);
return $form;
------------------Form------------------------------------
Comments
Comment #1
tobiberlinI want to add that theme_multiselect does not work as well. I can not override this theme function in a custom theme - and any changes in this function directly do not have any effect.
Comment #2
darbogast commentedI'm experiencing this exact issue, has there been any progress on how to fix this or how to avoid it?
Comment #3
nasirm commentedI modified the code in my local instance a long back but did not commit any patch. I changed function theme_multiselect in the module file multiselect.module and it worked for me.
Comment #4
nicxvan commentedThis seems to still be an issue: I have attached a screenshot and my implementation is below.
Comment #5
dsudheesh commentedRolled out a patch from @nasirm.
Thanks,
Sudheesh
Comment #6
dsudheesh commentedComment #7
tss commentedI have reviewed the patch in #5 and tested it. The multiselect works both when using it in FAPI and when using it as widget on entity fields.
Comment #8
rlangille commented+1 RTBC
This patch helped it start working with my admin forms. Without it element looked much like the screenshot in #4 and did not function.
Should note since this is a few years later... I'm running Drupal 7.64 and multiselect 7.13, and patch works well.
Comment #9
tylerh111 commentedThis patch worked for me: Drupal 7.67 and Multiselect 7.13.
Comment #10
mparker17multiselect-7.x-1.x is no longer supported, because Drupal 7 is no longer supported.
Can you confirm if this is still an issue in multiselect-2.0.0-beta4?
I'm going to mark this issue as "Postponed (maintainer needs more info)"... but when you answer, please change it back to "Active". If there is no reply in ~6 months, then I will mark this issue as "Closed (outdated)". Thank you in advance for your understanding and patience as I try to keep this module's issue queue clear.