Custom Fields
Re-Envisioned
Support MB Term Meta Required Custom Taxonomy Field - Not Required

  • Creator
    Topic
  • #32463
    Nic
    Participant

    Hello,

    I run the latest version of Metabox and WordPress multisite. I noticed today that for a custom taxonomy with custom fields made with Metabox, required fields are not required. So, even though I have marked the taxonomies custom fields as "required" the user can still create a new taxonomy post while leaving those required fields empty.

    Is this an issue anyone else has run into? Is there an option I am missing or a way to fix it?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
    Replies
  • #32472
    Long Nguyen
    Moderator

    Hi Nic,

    Can you please share the code that creates custom fields on your site? I will re-check it on my site.

    #32484
    Nic
    Participant

    Here it is:

    <?php
    add_filter( 'rwmb_meta_boxes', 'your_prefix_function_name' );
    
    function your_prefix_function_name( $meta_boxes ) {
        $prefix = '';
    
        $meta_boxes[] = [
            'title'      => __( 'Shifts', 'your-text-domain' ),
            'id'         => 'shifts',
            'taxonomies' => ['shift'],
            'fields'     => [
                [
                    'name'        => __( 'Start Time', 'your-text-domain' ),
                    'id'          => $prefix . 'shift-start-time',
                    'type'        => 'time',
                    'placeholder' => __( 'Military Time', 'your-text-domain' ),
                    'required'    => true,
                    'tooltip'     => [
                        'icon'     => '',
                        'position' => 'top',
                        'content'  => 'Provide the time that the clinical shift starts in military time.',
                    ],
                ],
                [
                    'name'        => __( 'End Time', 'your-text-domain' ),
                    'id'          => $prefix . 'shift-end-time',
                    'type'        => 'time',
                    'placeholder' => __( 'Military Time', 'your-text-domain' ),
                    'required'    => true,
                    'tooltip'     => [
                        'icon'     => '',
                        'position' => 'top',
                        'content'  => 'Provide the time that the clinical shift ends in military time.',
                    ],
                ],
                [
                    'name'     => __( 'Total Hours', 'your-text-domain' ),
                    'id'       => $prefix . 'shift_total_hours',
                    'type'     => 'number',
                    'desc'     => __( 'In hours and minutes are decimals. Visit <a href="https://www.engineeringtoolbox.com/minutes-decimal-hours-d_1699.html">this website for minute decimal values.</a>', 'your-text-domain' ),
                    'min'      => 0,
                    'max'      => 24,
                    'std'      => 12,
                    'required' => true,
                    'tooltip'  => [
                        'icon'     => '',
                        'position' => 'top',
                        'content'  => 'How many total hours will the student be at the clinical site for this shift? To display hours and minutes use decimals. .',
                    ],
                ],
            ],
        ];
    
        return $meta_boxes;
    }
    #32486
    Long Nguyen
    Moderator

    Hi,

    Thanks, I see that issue. I've escalated it to the development team to fix it in the next update.

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