I have programmatically set a text CCK to a select and given a few choices:

function mymodule_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'views_exposed_form' && $form_state['view']->name == 'myview') {
    // Add our custom All buttons.
    $form['field_1hour_currency']['#type'] = 'select';
    $form['field_1hour_currency']['#options'] = array(
      '' => t('<Any>'),
      'USD' => 'USD',
      'EUR' => 'Euro'

But this display defaults to a Multiple Choice box, and I want it to be a dropdown list. How can I set programmatically a select to force single so it displays a dropdown list?

Thank you


Add the following to your form_alter implementation:

$form['field_1hour_currency']['#multiple'] = FALSE;
$form['field_1hour_currency']['#size'] = 0;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.