Custom Fields
Re-Envisioned
Support Meta Box Group Add New term - Taxonomy Advanced in Group

  • Creator
    Topic
  • #29561
    hlikes
    Participant

    Hi, is it possible to:

    1) Put a Taxonomy Advanced field within a cloneable group?

    2) Use the "Add New" feature to allow users to add a new term while using the field as indicated in point 1) above?

    If I manually create the term before going to edit the post, I can select it from the dropdown and it is saved successfully, but I cannot get a new term to be saved directly from the post editing page.

    If not, is there a hook I can use to try and save the term, return the newly created term id, and pass it on to the specific row in the group before the post is saved? Hope that makes sense... Your input would be much appreciated.

    An extract from my code:

    function hls( $meta_boxes ) {
        $prefix = 'hls_';
    
        $meta_boxes[] = [
            'title'        => __( 'Player Profile', 'hls-text-domain' ),
            'id'           => 'sasra-player-profile',
            'post_types'   => ['sasra_player'],
            'include'      => [
                'relation'  => 'OR',
                'user_role' => ['administrator'],
            ],
            'storage_type' => 'custom_table',
            'table'        => 'sasra_player_profile_txt',
            'fields'       => [
    
                [
                    'name'        => __( 'Injuries', 'hls-text-domain' ),
                    'id'          => $prefix . 'sasra_player_injuries',
                    'type'        => 'group',
                    'collapsible' => true,
                    'group_title' => '{hls_injury_date_txt}',
                    'clone'       => true,
                    'sort_clone'  => true,
                    'add_button'  => __( 'Add Injury', 'hls-text-domain' ),
                    'fields'      => [
                        [
                            'name'    => __( 'Date', 'hls-text-domain' ),
                            'id'      => $prefix . 'injury_date_txt',
                            'type'    => 'text',
                            'desc'    => __( 'Year in which injury occured', 'hls-text-domain' ),
                            'columns' => 4,
                        ],
                        [
                            'name'           => __( 'Injury', 'hls-text-domain' ),
                            'id'             => $prefix . 'injury_type_tax',
                            'type'           => 'taxonomy_advanced',
                            'taxonomy'       => ['sasra_player_injury'],
                            'field_type'     => 'select',
                            'add_new'        => true,
                            'remove_default' => true,
                            'columns'        => 8,
                        ],
                    ],
                ],
            ],
        ];
    
        return $meta_boxes;
    }
Viewing 1 replies (of 1 total)
  • Author
    Replies
  • #29566
    Long Nguyen
    Moderator

    Hi,

    Thank you for your feedback.

    The new term is only created after publishing the post. I will inform the development team to support this case in future updates.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.