I have created new form components using '#type' => 'multiselect'.

Here I need to change the labels Available options, Selected options to some other text.
How can we do it through custom code. Can anyone suggest me.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

attheshow’s picture

You might want to take a look here. These are some good easy methods I've seen used before for something like this: https://drupal.org/node/522036

rameshbabu.g’s picture

Thanks for your quick response. I already tried String Overrides module in local and it is working fine.

Your pasted link contains 2 methods. So method 1 is more sufficient to me because it is a quick method for small number of strings.

$conf['locale_custom_strings_en'][''] = array(
'Available options' => 'Available Groups',
'Selected options' => 'Assigned Groups',
);

But here I am using '#type' => 'multiselect' in multiple forms. So I need different labels in different places. Is there any way to change strings conditionally.

attheshow’s picture

You could try using hook_form_alter() in a custom module.

stefanos.petrakis@gmail.com’s picture

This was an issue for us, we solved this using this patch, that offers the following two options to FAPI array:

  • '#available_options_label' => t('Custom label for options'),
  • '#selected_options_label' => t('Custom label for selected items'),

Thanks for reviewing this!

stefanos.petrakis@gmail.com’s picture

Status: Active » Needs review