Forum Replies Created
-
AuthorPosts
-
Anh Tran
KeymasterI think you can do that with custom JS code. The idea is:
- Enqueuing a JS file for Add New/Edit pages
- Call jQueryUI sortable methodThe pseudo-code might look like this:
add_action( 'admin_enqueue_scripts', function() { $screen = get_current_screen(); if ( 'team' == $screen->post_type && 'post' === $screen->base ) { wp_enqueue_script( 'prefix-sort-field', get_theme_directory_uri() . '/js/sort.js', array( 'jquery-ui-sortable' ) ); } } );And in
sort.js:jQuery( function ( $ ) { $( '.rwmb-input' ).sortable(); } );Hope that helps.
Anh Tran
KeymasterIt does have clear floats, of course. But the thing is the plugin needs correct number of columns to output correct opening and closing divs. You can see it in the console like this:

Here is an example to illustrate what I meant in previous reply: assuming we have 2 rows, 1st row has 2 fields (each field has 1/4 width), 2nd row has 4 fields (each field has 1/4 width):
add_filter( 'rwmb_meta_boxes', function () { return [ [ 'title' => 'Demo columns', 'fields' => [ [ 'id' => 'text1', 'type' => 'text', 'name' => 'Text1', 'columns' => 3, ], [ 'id' => 'text2', 'type' => 'text', 'name' => 'Text2', 'columns' => 3, ], [ 'type' => 'custom_html', 'std' => '', 'columns' => 6, ], [ 'id' => 'text5', 'type' => 'text', 'name' => 'Text5', 'columns' => 3, ], [ 'id' => 'text6', 'type' => 'text', 'name' => 'Text6', 'columns' => 3, ], [ 'id' => 'text7', 'type' => 'text', 'name' => 'Text7', 'columns' => 3, ], [ 'id' => 'text8', 'type' => 'text', 'name' => 'Text8', 'columns' => 3, ], ], ] ]; } );Anh Tran
KeymasterHi, I think there must be some JS errors which prevent the editor to be rendered properly. Do you see any errors in browser console?
Anh Tran
KeymasterHi catarinacarraro,
Thanks for your question, unfortunately, we're currently not support that feature yet. We'll mention it to think a way to improve our Conditional Logic.
Thanks and Best Regards.
Tan Nguyen
Anh Tran
KeymasterAn easy way to do that is keep adding 4 fields for columns, but you can use a special field like
custom_htmlwith zero content. That forces the plugin to output empty divs in the column which helps to maintain the layout.Anh Tran
KeymasterHi, currently the
rwmb_metafunction usesget_terms()internally and this function doesn't return terms in hierarchical order. I think the best way for now is going through the returned items, looking forparentparameter to get the correct order.Anh Tran
KeymasterHi catarinacarraro,
I've just tested with your code and I see the
stdvalue works, the radio with value "Em" is checked by default:
Anh Tran
KeymasterCan you please send me your meta box code? So I can fix it for you.
Anh Tran
KeymasterHi catarinaarraro,
As your logic, this is my snippet, you can edit to fit to your project:
add_filter( 'rwmb_meta_boxes', function( $meta_boxes ) { $meta_boxes[] = array( 'id' => 'brand_product', 'title' => 'Brands and Products', 'post_types' => array( 'post', 'page' ), 'context' => 'normal', 'priority' => 'high', 'fields' => array( array( 'id' => 'fone_id', 'name' => 'Brand', 'desc' => 'Pick Your Favourite Brand', 'type' => 'select', 'options' => array( 'apple' => 'Apple', 'android' => 'Android', 'windowsphone' => 'WindowsPhone' ) ), array( 'id' => 'apple_products', 'name' => 'Select your apple product?', 'type' => 'checkbox_list', 'options' => array('iPhone', 'iPad', 'iPod'), 'visible' => array( 'fone_id', '=', 'apple' ) ), array( 'id' => 'android_products', 'name' => 'Select your android product?', 'type' => 'checkbox_list', 'options' => array('Galaxy', 'ZenPhone', 'Tablet'), 'visible' => array( 'fone_id', '=', 'android' ) ), array( 'id' => 'windowsphone_products', 'name' => 'Select your apple product?', 'type' => 'checkbox_list', 'options' => array( 'Nokia', 'Galaxy' ), 'visible' => array( 'fone_id', '=', 'windowsphone' ) ) ) ); return $meta_boxes; } );Best regards
Tan Nguyen
Anh Tran
KeymasterI'm really sorry that you have spent much of time searching for the solution. I was on a holiday last week and couldn't answer you sooner. Hope you be generous and still love the plugin.
Anh Tran
KeymasterHi, in order to convert data from 1 format to another format, you need to understand how data is saved in the database. Here is the documentation for this. For group, data is saved as an array, each element of which is the value of sub-fields.
In this case, if you are using simple
textfield, your data is just multi rows in the database, so getting values will not be a big problem. But I'm not clear how you want to put them in a group? Will the text field is a sub-field of the new group? If so, you can use the following code:<?php $text_id = 'TEXT_FIELD_ID'; $group_id = 'GROUP_FIELD_ID'; $posts = get_posts( array( 'posts_per_page' => -1, ) ); foreach ( $posts as $post ) { $text = rwmb_meta( $text_id, 'type=text', $post->ID ); $meta_key = "{$group_id}[{$text_id}]"; update_post_meta( $post->ID, $meta_key, $text ); // delete_post_meta( $post->ID, $text_id ); // Remove old data, use with care }Anh Tran
KeymasterI think I understand now, but it's still better to have screenshots ๐
Anh Tran
KeymasterHi, you can use
postfield with'post_type' => 'page'.Anh Tran
KeymasterHi Flickweert,
I'm not very clear about the bug. Do you mean that when adding
max_clone, it still allows you to add infinite number of clones? And when you remove a clone, the "Add more" button disappear?Anh Tran
KeymasterHi Flikweert,
I understand your concern, but there's no way to handle image upload in the group for now.
But you can use another way to achieve that by using
file_inputfield. It works similar to all image fields (can Browse or Upload images), but doesn't have preview. It's not 100% perfect for your needs, but it works for now. -
AuthorPosts