Custom Fields
Re-Envisioned
Support MB Admin Columns File Upload field do not show in admin Column

  • Creator
    Topic
  • #32117
    Resolved Régis Evennou
    Participant

    Hi,
    I use the builder to create a field group. The File Upload field shows well when i create the field, but when i change the field order in the group, it does no show any more.
    How can i fix it ?
    Thank you

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

    Hi,

    I do not see that issue on my end. Can you please share the code that creates the file upload field before and after re-ordering?

    #32138
    Régis Evennou
    Participant

    Hi,
    Here is the code.
    Thank you 🙂

    <?php
    add_filter( 'rwmb_meta_boxes', 'your_prefix_function_name' );
    
    function your_prefix_function_name( $meta_boxes ) {
        $prefix = '';
    
        $meta_boxes[] = [
            'title'      => __( 'Demande de résidence', 'your-text-domain' ),
            'id'         => 'cie-submit',
            'post_types' => ['espace-cie'],
            'fields'     => [
                [
                    'name' => __( 'Description du projet de résidence', 'your-text-domain' ),
                    'id'   => $prefix . 'description_du_projet_de_residence',
                    'type' => 'wysiwyg',
                ],
                [
                    'name'          => __( 'Nom de l\'auteur', 'your-text-domain' ),
                    'id'            => $prefix . 'nom_de_l\'auteur',
                    'type'          => 'text',
                    'desc'          => __( 'Le nom de l\'auteur du texte', 'your-text-domain' ),
                    'admin_columns' => 'after discipline_artistique',
                ],
                [
                    'name' => __( 'Distribution / Equipe', 'your-text-domain' ),
                    'id'   => $prefix . 'distribution_equipe',
                    'type' => 'wysiwyg',
                ],
                [
                    'name'          => __( 'Période souhaitée', 'your-text-domain' ),
                    'id'            => $prefix . 'periode_souhaitee',
                    'type'          => 'text',
                    'admin_columns' => 'after partenaires_du_projet',
                ],
                [
                    'name'          => __( 'Discipline artistique', 'your-text-domain' ),
                    'id'            => $prefix . 'discipline_artistique',
                    'type'          => 'text',
                    'admin_columns' => 'after title',
                ],
                [
                    'name'          => __( 'Image', 'your-text-domain' ),
                    'id'            => $prefix . 'artiste_image',
                    'type'          => 'image',
                    'admin_columns' => 'after title',
                ],
                [
                    'name' => __( 'Partenaires du projet', 'your-text-domain' ),
                    'id'   => $prefix . 'partenaires_du_projet',
                    'type' => 'wysiwyg',
                ],
                [
                    'id'                => $prefix . 'hidden_cie_name',
                    'type'              => 'hidden',
                    'admin_columns'     => [
                        'position'   => 'after title',
                        'title'      => 'Nom de la cie',
                        'sort'       => true,
                        'searchable' => true,
                        'filterable' => true,
                    ],
                    'sanitize_callback' => 'nom_de_la_cie',
                ],
                [
                    'name'          => __( 'File Upload ok', 'your-text-domain' ),
                    'id'            => $prefix . 'file_upload_ok',
                    'type'          => 'file_upload',
                    'admin_columns' => [
                        'position' => 'after artiste_image',
                        'title'    => 'Dossier',
                    ],
                ],
            ],
        ];
    
        return $meta_boxes;
    }

    ---- AFTER -------------------------------

    <?php
    add_filter( 'rwmb_meta_boxes', 'your_prefix_function_name' );
    
    function your_prefix_function_name( $meta_boxes ) {
        $prefix = '';
    
        $meta_boxes[] = [
            'title'      => __( 'Demande de résidence', 'your-text-domain' ),
            'id'         => 'cie-submit',
            'post_types' => ['espace-cie'],
            'fields'     => [
                [
                    'name' => __( 'Description du projet de résidence', 'your-text-domain' ),
                    'id'   => $prefix . 'description_du_projet_de_residence',
                    'type' => 'wysiwyg',
                ],
                [
                    'name'          => __( 'File Upload ok', 'your-text-domain' ),
                    'id'            => $prefix . 'file_upload_ok',
                    'type'          => 'file_upload',
                    'admin_columns' => [
                        'position' => 'after artiste_image',
                        'title'    => 'Dossier',
                    ],
                ],
                [
                    'name'          => __( 'Nom de l\'auteur', 'your-text-domain' ),
                    'id'            => $prefix . 'nom_de_l\'auteur',
                    'type'          => 'text',
                    'desc'          => __( 'Le nom de l\'auteur du texte', 'your-text-domain' ),
                    'admin_columns' => 'after discipline_artistique',
                ],
                [
                    'name' => __( 'Distribution / Equipe', 'your-text-domain' ),
                    'id'   => $prefix . 'distribution_equipe',
                    'type' => 'wysiwyg',
                ],
                [
                    'name'          => __( 'Période souhaitée', 'your-text-domain' ),
                    'id'            => $prefix . 'periode_souhaitee',
                    'type'          => 'text',
                    'admin_columns' => 'after partenaires_du_projet',
                ],
                [
                    'name'          => __( 'Discipline artistique', 'your-text-domain' ),
                    'id'            => $prefix . 'discipline_artistique',
                    'type'          => 'text',
                    'admin_columns' => 'after title',
                ],
                [
                    'name'          => __( 'Image', 'your-text-domain' ),
                    'id'            => $prefix . 'artiste_image',
                    'type'          => 'image',
                    'admin_columns' => 'after title',
                ],
                [
                    'name' => __( 'Partenaires du projet', 'your-text-domain' ),
                    'id'   => $prefix . 'partenaires_du_projet',
                    'type' => 'wysiwyg',
                ],
                [
                    'id'                => $prefix . 'hidden_cie_name',
                    'type'              => 'hidden',
                    'admin_columns'     => [
                        'position'   => 'after title',
                        'title'      => 'Nom de la cie',
                        'sort'       => true,
                        'searchable' => true,
                        'filterable' => true,
                    ],
                    'sanitize_callback' => 'nom_de_la_cie',
                ],
            ],
        ];
    
        return $meta_boxes;
    }
    #32154
    Long Nguyen
    Moderator

    Hi,

    I see the issue. You need to register the field artiste_image before the field file_upload_ok to show the admin column after the field artiste_image.

    function your_prefix_function_name( $meta_boxes ) {
        $prefix = '';
    
        $meta_boxes[] = [
            'title'      => __( 'Demande de résidence', 'your-text-domain' ),
            'id'         => 'cie-submit',
            'post_types' => ['espace-cie'],
            'fields'     => [
                [
                    'name' => __( 'Description du projet de résidence', 'your-text-domain' ),
                    'id'   => $prefix . 'description_du_projet_de_residence',
                    'type' => 'wysiwyg',
                ],
                [
                    'name'          => __( 'Image', 'your-text-domain' ),
                    'id'            => $prefix . 'artiste_image',
                    'type'          => 'image',
                    'admin_columns' => 'after title',
                ],
                [
                    'name'          => __( 'File Upload ok', 'your-text-domain' ),
                    'id'            => $prefix . 'file_upload_ok',
                    'type'          => 'file_upload',
                    'admin_columns' => [
                        'position' => 'after artiste_image',
                        'title'    => 'Dossier',
                    ],
                ],
                ...
            ],
        ];
    
        return $meta_boxes;
    }
    #32180
    Régis Evennou
    Participant

    Ok thx 🙂

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