Cannot manage to work with a Select field in group
- This topic has 3 replies, 2 voices, and was last updated 9 years, 3 months ago by
closemarketing.
Viewing 4 posts - 1 through 4 (of 4 total)
-
AuthorPosts
-
July 21, 2016 at 10:30 PM #3714
closemarketing
ParticipantHow it will be the code?
I use this:
array( 'name' => esc_html__( 'Depends of', 'pbc' ), 'id' => "{$prefix}depends", 'type' => 'group', 'clone' => true, 'sort_clone' => true, 'fields' => array( // SELECT BOX VARIATIONS array( 'name' => __( 'Variation', 'pbc' ), 'id' => "{$prefix}depvar", 'type' => 'select', 'options' => $var_options, 'multiple' => false, 'std' => '', 'placeholder' => __( 'Select a Variation', 'pbc' ), ), ), ), //arrayJuly 22, 2016 at 9:36 AM #3721Anh Tran
KeymasterDid you set value for
$var_options? Here is my test:<?php add_filter( 'rwmb_meta_boxes', 'your_prefix_register_meta_boxes' ); function your_prefix_register_meta_boxes( $meta_boxes ) { $prefix = 'mbox_'; $var_options = array( 'a' => 'First option', 'b' => 'Second option', ); $meta_boxes[] = array( 'title' => esc_html__( 'Standard Fields', 'your-prefix' ), 'fields' => array( array( 'name' => esc_html__( 'Depends of', 'pbc' ), 'id' => "{$prefix}depends", 'type' => 'group', 'clone' => true, 'sort_clone' => true, 'fields' => array( // SELECT BOX VARIATIONS array( 'name' => __( 'Variation', 'pbc' ), 'id' => "{$prefix}depvar", 'type' => 'select', 'options' => $var_options, 'multiple' => false, 'std' => '', 'placeholder' => __( 'Select a Variation', 'pbc' ), ), ), ), //array ), ); return $meta_boxes; }And here is the result:
July 22, 2016 at 12:59 PM #3724closemarketing
ParticipantHello!, yes it loads all entries from a post type:
//Variations Options $var_options = array(); $variationscpt = get_posts(array( 'post_type' => 'variation', 'posts_per_page' => -1, 'orderby' => 'name', 'order' => 'ASC' )); $variationscpt_item = array(); foreach ($variationscpt as $var_item) { $var_options[$var_item->ID] = $var_item->post_title; }July 22, 2016 at 2:44 PM #3725closemarketing
ParticipantHello, I've found the error. I was using meta-box as composer, and it was not working...
Now as plugin it works correctly.
-
AuthorPosts
Viewing 4 posts - 1 through 4 (of 4 total)
- The topic ‘Cannot manage to work with a Select field in group’ is closed to new replies.