29. Multiselect

Multiselect enables to selection of different options from the list to the corresponding setting:

There is also an availability to add new elements to the list right from the Multiselect:

'tab_title_selected_labels' => array(
   'type'    => 'multiselect',
   'label'   => esc_html__( 'Add features to the list', 'stm_vehicles_listing' ),
   'options' => $this->motors_get_features_list(),
   'new_tag_settings' => array(
      'add_label'     => esc_html__( 'Add New Feature', 'stm_vehicles_listing' ),
      'taxonomy_name' => 'stm_additional_features',
      'placeholder'   => 'Enter feature name',
      'add_btn'       => 'Add',
      'cancel_btn'    => 'Cancel',
   ),
),

#new_tag_settings - to insert the 'Add New' button

If you have some elements in one list of options, you have to add a unique selector and specify it in config under the key track_by

'multiselect_2' => array(
    'type' => 'multiselect',
    'label' => esc_html__( 'Multiselect', 'my-domain' ),
    'options' => array(
        array(
            'label' => 'My super title 1',
            'value' => '1'
        ),
        array(
            'label' => 'My super title 1',
            'value' => '2'
        ),
    ),
    'track_by' => 'value'
),

Last updated

Was this helpful?