Custom Fields
Re-Envisioned
Support General Select field not always saving depending on how the OPTIONS array is being built

  • Creator
    Topic
  • #17161
    EdT
    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,
                  ),
    
              
    
            )
        );
    
Viewing 1 replies (of 1 total)
  • Author
    Replies
  • #17163
    EdT
    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 1 replies (of 1 total)
  • You must be logged in to reply to this topic.