Select field not always saving depending on how the OPTIONS array is being built

Support General Select field not always saving depending on how the OPTIONS array is being built

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #17161
    EdTEdT
    Participant

    For some reason my select field is not saving the value when I display the options this way,

    'options' => array(
                    array( 'value' => 'value1', 'label' => 'Label1' ),
                    array( 'value' => 'value2', 'label' => 'Label2' ),
                    array( 'value' => 'value3', 'label' => 'Label3' ),
    

    And it is working fine when options are displayed this way

    'options' => array(
                 'value1'       => 'label1',
                 'value1'       => 'label1',
                 'value1'       => 'label1',
    ),

    The problem is that I want to list the terms of a Taxonomy associated with another custom post type and I don't seems to be able to display the list of term and save the selected value using the 2 way of displaying the options.
    Here is the actual code I use:

    
    $optionsaddressloop = array();
        $terms = get_terms( array(
            'taxonomy' => 'partner_address_firm',
            'hide_empty' => false,
        ) );
        foreach ($terms as $term) {
          $optionsaddressloop[] = array(
              'value' => $term->slug,
              'label' => $term->slug,
              );
              }
    
    $meta_boxes[] = array(
            'id'         => 'partner-admin-fields',
            'title'      => 'Partner Firm Admin Custom Fields',
            'post_types' => 'partner',
            'context'    => 'normal',
            'priority'   => 'high',
    
            'fields' => array(
              array(
                  'name'  => 'Term for Address Loop',
                  'id'    => $prefix . 'firm_term_address_loop',
                  'type'  => 'select_advanced',
                  'multiple'        => false,
                  'placeholder'  => '-- select --',
                  'options' => $optionsaddressloop,
                  ),
    
              
    
            )
        );
    
    #17163
    EdTEdT
    Participant

    Not sure if it is the same issue, but when using the metabox builder, it saves value for select_advanced fields, but not for regular select fields...

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.