Support Forum » User Profile

Forum Replies Created

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • in reply to: Empty Fields after UPDATE #41980
    Marius GünterMarius Günter
    Participant

    Still have a error with breakdance since latest Update.

    Marius GünterMarius Günter
    Participant

    ...or is there a quick fix / patch?

    Marius GünterMarius Günter
    Participant

    Hi there,

    I have the same problem.
    I have a settings page with a group. Inside that group there is a taxonomy_advanced field.
    When I save the settings page, the selected values of the taxonomy_advanced field aren't saved anymore.

    When does it be fixed?

     [
                'name'       => '',
                'id'         => 'options_cat',
                'type'       => 'group',
                'clone'      => true,
                'sort_clone' => true,
                'add_button' => 'Hinzufügen',
                'fields'     => [
                    [
                        'name'    => 'Posttype',
                        'id'      =>  'cpt',
                        'type'    => 'select',
                        'options'         => [
                            'video'   => 'Video',
                            'podcast' => 'Podcast',
                            'event'    => 'Termin',
                            'post'     => 'Blog',
                            'forum'     => 'Forum',
                        ],
                        'columns' => 2,
                    ],
                    [
                        'name'        => 'Kategorien',
                        'id'          => 'terms',
                        'type'        => 'taxonomy_advanced',
                        'taxonomy'    => ['category'],
                        'field_type'  => 'checkbox_list',
                        'placeholder' => 'Kategorie auswählen',
                        'multiple'    => true,
                        'columns' => 10,
                    ],
                ],
            ],
    in reply to: Default values of hidden field in clone group #35539
    Marius GünterMarius Günter
    Participant

    I am facing the exact same problem.

    After going through the code, I came to the conclusion, that it is currently not possible.

    First of all, you cannot set a default of '0' (type=string). Internally the std value is checked against empty() (see RWMB_Group_Field::child_field_std). Unfortunately, empty( '0' ) === true.

    Next, Metabox' client-side cloning completely ignores hidden fields (see https://github.com/wpmetabox/meta-box/blob/master/js/clone.js#L91-L102). The cloning is implemented by copying the HTML of the previous element and then applying some functions on the newly inserted fields. Usually, at that time, the default values are set.

    in reply to: Select fields do not show values in MB Group #31656
    Marius GünterMarius Günter
    Participant

    Hi,
    you could use a workaround. Use a simple "Select" field and fill the options with the term data from get terms. To get the terms use get_terms inside the "init" action hook.
    For Example:

    add_filter( 'init', function() {
        $terms = get_terms(
            [
                'taxonomy' => 'THE_TAXONOMY',
                'hide_empty' => false
            ]
        );
        $terms_data = [];
        foreach( $terms as $term ) {
            $terms_data[ $term->term_id ] = $term->name;
        }
        add_filter( 'rwmb_meta_boxes', function( $meta_boxes ) use ( $terms_data ) {
            meta_boxes[] = [
               'title'      => 'THE_METABOX',
               'post_types' => 'THE_POSTTYPE',
               'fields' => [
                [
                    'name'  => 'THE_FIELD_NAME',
                    'id'    => 'THE_FIELD_ID',
                    'type'  => 'group',
                    'fields' => [
                        [
                          'name' => 'THE_SELECT_FIELD_NAME',
                          'id' => 'THE_SELECT_FIELD_ID',
                          'type' => 'select',
                          'options' => $terms_data,
                       ],
                    ]
                ],
            ];
            return $meta_boxes;
       });
    }
Viewing 5 posts - 1 through 5 (of 5 total)