File advanced not rendered correctly

Support General File advanced not rendered correctlyResolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #26770
    lucabilucabi
    Participant

    Hi, I've tried to add a File advanced field in a custom post type using the same example provided in documentation:

     $meta_boxes[] = array(
                'title'      => 'File',
                'post_types' => $this->post_type_name,
        
                'fields' => array(
                    'id'               => 'file',
                    'name'             => 'File Advanced',
                    'type'             => 'file_advanced',
                
                    // Delete file from Media Library when remove it from post meta?
                    // Note: it might affect other posts if you use same file for multiple posts
                    'force_delete'     => false,
                
                    // Maximum file uploads.
                    'max_file_uploads' => 2,
                
                    // File types.
                    // 'mime_type'        => 'application,audio,video',
                
                    // Do not show how many files uploaded/remaining.
                    'max_status'       => 'false',
                    'multiple' => false
                ),
            );

    but the control is rendered as 7 plain input controls.

    I'm using WordPress 5.7. It makes no difference if I set Gutemberg or classic editor in the post type settings.

    Kind regards, Luca

    #26774
    Long NguyenLong Nguyen
    Moderator

    Hi,

    The fields key is an array of field arrays, it should be

    $meta_boxes[] = array(
        'title'      => 'File',
        'post_types' => 'post',
    
        'fields' => array(
            array(
                'id'               => 'file',
                'name'             => 'File Advanced',
                'type'             => 'file_advanced',
            
                // Delete file from Media Library when remove it from post meta?
                // Note: it might affect other posts if you use same file for multiple posts
                'force_delete'     => false,
            
                // Maximum file uploads.
                'max_file_uploads' => 2,
            
                // File types.
                // 'mime_type'        => 'application,audio,video',
            
                // Do not show how many files uploaded/remaining.
                'max_status'       => 'false',
                'multiple' => false
            ),
            array(
                // another field
            ),
        ),
    );

    Get more details on this basic documentation https://docs.metabox.io/creating-meta-boxes/.

    #26776
    lucabilucabi
    Participant

    Thank you very much, my fault sorry. The fact that something was rendered misled me.

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