• Resolved Begin

    (@bentalgad)


    When i use this code:

    $pro_paypal_box->add_group_field( $pro_paypal_kidum, array(
    'name' => 'place',
    'id' => 'place',
    'type' => 'select',
    'show_option_none' => true,
    'options' => $places_options,
    ) );
    $pro_paypal_box->add_group_field( $pro_paypal_kidum, array(
    'name' => 'kidum_state',
    'id' => 'state',
    'type' => 'select',
    'show_option_none' => true,
    'default' => 'active',
    'options' => array(
    'active' => 'active',
    'canceled' => 'canceled',
    ),
    ) );

    I get ‘canceled’ as default option.

Viewing 15 replies - 16 through 30 (of 35 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    not sure I’m managing to recreate at all, however, let’s outline some steps.

    You create and fill out a grouping. Hit save.
    After that, you create a new grouping, and remove the first one?
    Once you remove the first one, the 2nd one you had created inherited the values from the first one?

    Alternative:
    You create and fill out a grouping. Hit save.
    After that, you decide you don’t want that initial one, and remove it.
    All groups you create afterwards inherit the values from the first one?

    Thread Starter Begin

    (@bentalgad)

    I reset the field (let’s start clean) by doing:
    update_post_meta( '882', 'pro_paypal_kidum', '' ); and then hit “update” on the edit post page.

    Then i add values to the first (only) group. hit “update”.

    Now when i add another group (no matter how many of them) they all have the same values of the first one. btw – only the text fields. the select fields are blank (like suppose to be).

    • This reply was modified 7 years, 3 months ago by Begin.
    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Really hard for me to say with that detail regarding the text fields. Your configuration code is set to have them all be read-only, and I don’t have any way of knowing what may have been done in the past to provide values for them.

    Thread Starter Begin

    (@bentalgad)

    only added values by using:

    $my_group = get_post_meta( $propostid, 'pro_paypal_kidum', true );
    $my_group[] = array( 'place' => $stickyplaceid, 'state' => 'active', 'payer_mail' => $payer_email, 'start' => $format_action_date->format('d/m/Y'), 'subscr_id' => $subscr_id, 'price' => $mc_amount3, 'fee' => $mc_fee);
    update_post_meta( $propostid, 'pro_paypal_kidum', $my_group );
    Thread Starter Begin

    (@bentalgad)

    Also tried removing all the readonly attributes and edit the field values manually in the edit post page. still will add the next one with the values of the last one.

    • This reply was modified 7 years, 3 months ago by Begin.
    Thread Starter Begin

    (@bentalgad)

    Another point: when i have only one group field and i hit “remove group” it won’t clear the values (it’s suppose to in the last version right?)

    Thread Starter Begin

    (@bentalgad)

    Another very interesting point now i see: (following the last comment) it will clear the select fields!

    Thread Starter Begin

    (@bentalgad)

    Also tried to change the group field’s id so it will clear anything associated with that field. still same problem.

    Thread Starter Begin

    (@bentalgad)

    Here is a screencast gif of the problem.

    • This reply was modified 7 years, 3 months ago by Begin.
    • This reply was modified 7 years, 3 months ago by Begin.
    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    One thing I do want to remind of and keep in mind is that this is very much a new feature that was just added in the past 24 hours. Is possible that some details slipped by.

    @jtsternberg I was able to finally recreate this, and it feels like https://github.com/CMB2/CMB2/issues/853 started occurring for text fields now.

    Steps that recreated for me:
    * Add a new post
    * Add some meta to a group, specifically text fields
    * Save the post
    * Add a new group
    * Note that text fields are pre-populated.

    CMB2 config that worked for me for this, don’t forget to change the post type to somethin you have registered:

    add_action( 'cmb2_init', 'add_pro_paypal_box' );
    function add_pro_paypal_box() {
    	global $listmesettings_id;
    
    	$pro_paypal_box = new_cmb2_box( array(
    		'id'           => '_pro_paypal_box',
    		'title'        => '???? ????? ????????',
    		'object_types' => array( 'movie' ),
    		'context'      => 'normal',
    		'priority'     => 'high',
    	) );
    
    	// Kidum group
    	$pro_paypal_kidum = $pro_paypal_box->add_field( array(
    		'id'          => 'pro_paypal_kidum',
    		'type'        => 'group',
    		'options'     => array(
    			'group_title'   => 'group {#}',
    		),
    	) );
    	$pro_paypal_box->add_group_field( $pro_paypal_kidum, array(
    		'name' => '????',
    		'id' => 'place',
    		'type' => 'select',
    		'show_option_none' => true,
    		'options' => array( 1 => 'something' ),
    	) );
    	$pro_paypal_box->add_group_field( $pro_paypal_kidum, array(
    		'name' => '??? ?????',
    		'id' => 'state',
    		'type' => 'select',
    		'show_option_none' => true,
    		'options' => array(
    			'active' => '????',
    			'canceled' => '?????',
    		),
    	) );
    	$pro_paypal_box->add_group_field( $pro_paypal_kidum, array(
    		'name' => '???? ?? ????? ????',
    		'id' => 'payer_mail',
    		'type' => 'text',
    	) );
    	$pro_paypal_box->add_group_field( $pro_paypal_kidum, array(
    		'name' => '?????',
    		'id' => 'start',
    		'type' => 'text_small',
    	) );
    	$pro_paypal_box->add_group_field( $pro_paypal_kidum, array(
    		'name' => '????',
    		'id' => 'end',
    		'type' => 'text_small',
    	) );
    	$pro_paypal_box->add_group_field( $pro_paypal_kidum, array(
    		'name' => '???? ????? ????',
    		'id' => 'subscr_id',
    		'type' => 'text_small',
    	) );
    	$pro_paypal_box->add_group_field( $pro_paypal_kidum, array(
    		'name' => '????',
    		'id' => 'price',
    		'type' => 'text_small',
    	) );
    	$pro_paypal_box->add_group_field( $pro_paypal_kidum, array(
    		'name' => '????',
    		'id' => 'fee',
    		'type' => 'text_small',
    	) );
    }
    
    Thread Starter Begin

    (@bentalgad)

    thanks! can you explain what exactly in the code that you posted is fixing the problem?

    Thread Starter Begin

    (@bentalgad)

    Doesn’t seem to fix it for me.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    The code I posted doesn’t have a fix, it’s just a modified version of what you posted earlier to make it render on my end. I was posting it for Justin to use for any testing he wants to try.

    If you want to @bentalgad, you can read over issue 853 that I linked above.

    Thread Starter Begin

    (@bentalgad)

    Oh, ok, it sounded like that, but i wasn’t sure ??

    Let me know if you need me to test something else to figure this out…

    Thanks!

    Plugin Author Justin Sternberg

    (@jtsternberg)

    Michael is saying “it works” in that he is able to replicate your issue. And so was I.

    I narrowed the issue down to being specific to groups which do not have the 'sortable' option set to true: https://github.com/CMB2/CMB2/blob/trunk/example-functions.php#L489

    As a temporary workaround, you can add the ‘sortable’ param and it will work. I will push up a hotfix shortly.

Viewing 15 replies - 16 through 30 (of 35 total)
  • The topic ‘The default parameter don’t work in group fields’ is closed to new replies.