Categories
CMS Development Drupal

Drupal form select not showing any options

I have created a form select with option values but options are not showing in the select element. Can any one please give me suggestion.

enter image description here

    $form['assets_type'] = array(
        '#type' => 'select',
        '#title' => t('Digital Asset Types'),    
        '#options' => (get_optgroup_by_taxonomy('asset_type')),
        '#multiple' => TRUE,
        '#default_value' => $type_checked,
        '#attributes' => [
          'data-placeholder' => 'All Asset Types'
        ]
      );

      $form['therapy'] = array(
        '#type' => 'select',
        '#multiple' => TRUE,
        '#title' => t('Therapy'),    
        '#options' => array(
          0 => 'You cannot select this'
          1 => 'One',
          2 => 'Two',
          3 => 'Three',
          'all' => 'With a data attribute',
        ),
        "#empty_option"=>t('- Select -'),
        '#attributes' => [
          'data-placeholder' => 'All Therapies'
        ]
      );

Leave a Reply

Your email address will not be published. Required fields are marked *