New custom taxonomy term not saved when added within custom field

Support General New custom taxonomy term not saved when added within custom field

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #29521
    VoBVoB
    Participant

    Hi!

    We have a custom advanced taxonomy field which we want to mark as required. We also want editors to add new terms when creating a post. While there are such settings provided by Meta Box they do not work. After adding a new term within the custom field the post cannot be saved as the newly added term is not persisted in DB and as the result it is not available in select.

    Another related issue is when you want to updated the value for such field. If you click "Add new term" and type in a new term in the open field and then click Update for the post, it saves second term entry to the database: the one in selector and another one in input field.

    Ideally, a new term should be persisted in DB either on Enter or on button click which states it clearly "Save (new term)" and the list in the selector should be reloaded and focused on the newly added term.

    Could you please check this issue?

    Thanks!

    <?php
    add_filter( 'rwmb_meta_boxes', 'your_prefix_function_name' );
    
    function your_prefix_function_name( $meta_boxes ) {
        $prefix = '';
    
        $meta_boxes[] = [
            'title'        => __( 'VoB Source for Article', 'your-text-domain' ),
            'id'           => 'vob-source-for-article',
            'post_types'   => ['vob-post-article'],
            'storage_type' => 'custom_table',
            'table'        => 'wp_custom_vob_source_for_article',
            'context'      => 'side',
            'priority'     => 'high',
            'fields'       => [
                [
                    'name'              => __( 'Source Name Tag', 'your-text-domain' ),
                    'id'                => $prefix . 'vob_article_source_name_tag',
                    'type'              => 'taxonomy_advanced',
                    'label_description' => __( 'Name of the publisher or web-site from taxonomy', 'your-text-domain' ),
                    'taxonomy'          => ['vob_source_name_tag'],
                    'field_type'        => 'select',
                    'placeholder'       => __( 'Select source name from the list', 'your-text-domain' ),
                    'add_new'           => true,
                ],
                [
                    'name'              => __( 'Source Name', 'your-text-domain' ),
                    'id'                => $prefix . 'vob_article_source_name',
                    'type'              => 'text',
                    'label_description' => __( 'Name of the publisher or web-site', 'your-text-domain' ),
                    'placeholder'       => __( 'Or add name of the publisher or web-site here', 'your-text-domain' ),
                ],
                [
                    'name'              => __( 'Source URL', 'your-text-domain' ),
                    'id'                => $prefix . 'vob_article_source_url',
                    'type'              => 'url',
                    'label_description' => __( 'Link to content source', 'your-text-domain' ),
                    'placeholder'       => __( 'Add source URL', 'your-text-domain' ),
                ],
                [
                    'name'              => __( 'Journalist / Author', 'your-text-domain' ),
                    'id'                => $prefix . 'vob_article_source_author',
                    'type'              => 'text',
                    'label_description' => __( 'Original article author name', 'your-text-domain' ),
                    'placeholder'       => __( 'Add article author', 'your-text-domain' ),
                ],
            ],
            'validation'   => [
                'rules' => [
                    $prefix . 'vob_article_source_name_tag' => [
                        'required' => true,
                    ],
                    $prefix . 'vob_article_source_url'      => [
                        'required' => true,
                        'url'      => true,
                    ],
                ],
            ],
        ];
    
        return $meta_boxes;
    }
    DESCRIBE 'wp_custom_vob_source_for_article'
    
    ID  bigint(20) unsigned NO  PRI 
        NULL
    
    vob_article_source_name_tag text    YES
        NULL
    
    vob_article_source_name text    YES
        NULL
    
    vob_article_source_url  text    YES
        NULL
    
    vob_article_source_author   text    YES
        NULL
    
    
    #29532
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Thank you for your feedback.

    The new term is only created after publishing the post. So users have to select another taxonomy as the requirement of the field. I will inform the development team to support this case in future updates.

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