• Resolved Angelo Rocha

    (@angelorocha)


    Hi!
    I using a field type text with the option “repeatable” and works fine, but, when i update post, after publish, the information on field lost.

    How to prevent this?!

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Can you provide the CMB2 config/callback you’re using for this so we can try to replicate as close as possible?

    Thanks

    Thread Starter Angelo Rocha

    (@angelorocha)

    Hi Michael, my code:

    
    if ( file_exists( dirname( __FILE__ ) . '/lib/cmb2/init.php' ) ) {
        require_once dirname( __FILE__ ) . '/lib/cmb2/init.php';
    } elseif ( file_exists( dirname( __FILE__ ) . '/lib/cmb2/init.php' ) ) {
        require_once dirname( __FILE__ ) . '/lib/cmb2/init.php';
    }
    

    Is it?

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    No, the code where you set up your fields and chose to create some text fields that are repeatable. Likely hooked onto cmb2_init or cmb2_admin_init.

    Thread Starter Angelo Rocha

    (@angelorocha)

    Thanks for replay Michael!

    See: https://pastebin.com/8H98kPdT

    Example a field problem in line 59.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    while my local install re-indexes, just to confirm, this is for the following field, correct?

    $sheet1->add_field( array(
    	'name'        => 'Período dos dados solicitados na Ordem de Servi?o (O.S.), data final:',
    	//'desc'    => 'field description (optional)',
    	//'default' => 'standard value (optional)',
    	'id'          => '_periodo_datafinal_1',
    	'type'        => 'text_date',
    	'date_format' => 'd/m/Y'
    ) );
    

    Initial hunches are that it’s perhaps saving to meta like expected, but for whatever reasons(dates are difficult), the jQuery UI aspect may be failing to parse/load that value.

    Thread Starter Angelo Rocha

    (@angelorocha)

    Michael, problem found.

    Data fields store in wrong format, cmb try solve but lost data, i fix it in my field list and “data_format” paramms.

    Thanks for your attention.

    Solution:

    
    ...
        $sheet1->add_field( array(
            'name' => 'Período dos dados solicitados na Ordem de Servi?o (O.S.), data inicial:',
            //'desc'    => 'field description (optional)',
            //'default' => 'standard value (optional)',
            'id' => '_periodo_data_1',
            'type' => 'text_date',
            'date_format' => 'Y-m-d'
        ) );
    ...
    
    • This reply was modified 6 years, 7 months ago by Angelo Rocha.
    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    glad i could almost get to help ??

    more glad you got it figured out.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Field type text with repeatable true – Lost data on post update’ is closed to new replies.