Forum Replies Created
-
AuthorPosts
-
August 7, 2017 at 2:46 PM in reply to: Conditional Logic does not work with MB Frontend Submission #6540
Tan Nguyen
ParticipantDear ludovic,
You're right. Conditional Logic currently only works in admin. I'll check the plugin and release new update asap!
Tan Nguyen
ParticipantDear zazezi,
Can you please try with another fresh install to test and post your code here so I can easy to replicate it?
Tan Nguyen
ParticipantDear zazezi,
Can you please open the Console and copy the error if you see? If it doesn't show any error message, can you please copy your code here?
Tan Nguyen
ParticipantYou're right. The Columns extension will wrap fields on 12 grid. That means two wysiwyg editors are in the same row and the remaining in the same row. There is a trick to wrap 3 columns in the same row, by setting the second column to column of 5 instead of 6:
array( 'name' => false, 'id' => "{$prefix}sect_editor", 'type' => 'wysiwyg', 'columns' => 6, 'raw' => true, 'options' => array( 'textarea_rows' => 15, 'wpautop' => false, ), ), array( 'name' => false, 'id' => "{$prefix}sect_editor2", 'visible' => ['uk_sect_layout', 'layout2'], 'type' => 'wysiwyg', 'columns' => 5, 'raw' => true, 'options' => array( 'textarea_rows' => 15, 'wpautop' => false, ), ), // Image Columns array( 'name' => esc_html__( 'Section Images', 'codice' ), 'id' => "{$prefix}sect_image", 'visible' => ['uk_sect_layout', 'layout1'], 'type' => 'image_advanced', 'columns' => 6, 'force_delete' => false, 'max_file_uploads' => 2, 'max_status' => false, ), // Layout options array( 'name' => esc_html__( 'Layout', 'codice' ), 'id' => "{$prefix}sect_layout", 'columns' => 3, 'type' => 'select', 'options' => array( 'layout1' => esc_html__( 'Image', 'codice' ), 'layout2' => esc_html__( '2 Columns', 'codice' ), ), ),Please try and let me know if you have any problem.
Cheers!
Tan Nguyen
ParticipantDear uththamag,
Sorry to make you feel confusing, I've checked both Columns and Conditional Logic and see it works as your requested. Please see my example and let me know if you have further problems.
July 18, 2017 at 2:26 AM in reply to: show hide columns fields in a same raw using the conditional logic #6345Tan Nguyen
ParticipantDear uththamag,
Imagine you have a field to select layout like so:
array( 'name' => __( 'Layout', 'rwmb' ), 'id' => 'layout', 'type' => 'select', 'columns' => 12, 'options' => array( 'one' => '1 Col', 'two' => '2 Cols', 'three' => '3 Cols' ) ),To toggle a field with selected value, just add:
'visible' => ['layout', 'SELECTED_VALUE'],SELECTED_VALUE can be
one,two, orthreelike the above example.July 18, 2017 at 2:15 AM in reply to: How to hide Metabox group according to taxonomy selection? #6344Tan Nguyen
ParticipantDear xoomserve,
Here is the example which I've created with MB Builder:
add_filter( 'rwmb_meta_boxes', 'your_prefix_register_meta_boxes' ); function your_prefix_register_meta_boxes( $meta_boxes ) { $meta_boxes[] = array ( 'id' => 'untitled-metabox-2', 'title' => 'Untitled Metabox', 'pages' => array ( 'post', 'page', ), 'context' => 'normal', 'priority' => 'high', 'autosave' => false, 'fields' => array ( array ( 'id' => 'properties', 'type' => 'taxonomy', 'name' => 'Properties', 'taxonomy' => 'product_type', 'field_type' => 'select', ), array ( 'id' => 'another_text_field', 'type' => 'text', 'name' => 'Text Field', 'visible' => array ( 'when' => array ( array ( 'taxonomy_2', '=', '4', ), ), 'relation' => 'and', ), ), ), ); return $meta_boxes; }Basically, you can register your taxonomy field and another field normally. And then, in related field (Text in this example), just define your conditional logic:
'visible' => ['your_taxonomy_id', '=', 'taxonomy_value']June 22, 2017 at 12:58 PM in reply to: "Oops something went wrong" in Address field on example.php meta box #6145Tan Nguyen
ParticipantDear Jason,
As you can see, it says Undefined index: badgeos in /home/40951-69099.cloudwaysapps.com/czfybpbunb/public_html/wp-content/themes/obodohub-cts-master-0.5.2/functions.php on line 438.
Can you please fix that warning?
Cheers!
Tan Nguyen
ParticipantDear bdthemes,
Here is an example:
add_filter( 'rwmb_meta_boxes', 'YOURPREFIX_register_meta_boxes' ); function YOURPREFIX_register_meta_boxes( $meta_boxes ) { // Define a meta box $meta_box = array( 'title' => __( 'Media', 'textdomain' ), 'post_types' => 'post', 'fields' => array( array( 'name' => __( 'URL', 'textdomain' ), 'id' => 'url', 'type' => 'text', ), ) ); // Add new field when condition meets if (get_theme_mod( 'orphan_toolbar')) { $meta_box['fields'][] = array( 'name' => 'Toolbar', 'id' => $prefix . "toolbar", 'type' => 'checkbox', 'desc' => 'Enable or disable the toolbar for this page.', 'tab' => 'layout', ), } // Add the meta box to $meta_boxes array to register $meta_boxes[] = $meta_box; }Tan Nguyen
ParticipantDear woorie,
Because toggle_type is affected to whole field/meta box and its container and many fields aren't normal form input field so it isn't possible. Sorry for that.
June 21, 2017 at 8:57 AM in reply to: "Oops something went wrong" in Address field on example.php meta box #6115Tan Nguyen
ParticipantDear Jason,
Can you please tell me your PHP version, in the example I use anonymous function so perhaps it doesn't works with PHP 5.2.
Btw, can you please turn on WP_DEBUG and/or WP_DEBUG_LOG to see the full output message. Kindly check the WP official documentation: https://codex.wordpress.org/Debugging_in_WordPress
Best regards,
TanTan Nguyen
ParticipantDear woorise,
The plugin is intended to show or hide field or meta box, it cannot disable a field.
Best,
Tan
Tan Nguyen
ParticipantDear bdthemes,
Conditional Logic works with Javascript callback only, it doesn't works with PHP, however, with PHP, you can check if meet a condition and then register meta box or field, like so:
if (get_theme_mod('orphan_toolbar')) { $meta_boxes = [ ... ]; }Tan Nguyen
ParticipantDear kotofey,
1. Yes, I'll add it to the next minor release this month.
2. Yes, I have already written a guide for you.
https://metabox.io/docs/hide-meta-box-tabs-conditional-logic/Tan Nguyen
ParticipantSound great. Yeah, I think in this case, thats best practice.
-
AuthorPosts