rwmb_frontend_validate for cloneable groups issue with set_post_data

Support MB Frontend Submission rwmb_frontend_validate for cloneable groups issue with set_post_data

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #48545
    Nicholas CoxNicholas Cox
    Participant

    Hi,

    When using rwmb_request()->set_post_data( $_POST ); when manipulating field values for cloneable groups during form validation, if you leave the clone empty or set any number of group clones then there is always an extra empty clone field saved to the database. I assume the cleanup operation for the forms cloneable groups is not removed before the post is created when using rwmb_request()->set_post_data( $_POST );?

    add_filter( 'rwmb_frontend_validate', function( $validate, $config ) {
    	//update clone fields then...
    	rwmb_request()->set_post_data( $_POST );
        return $validate;
    }, 10, 2 );

    ref: https://support.metabox.io/topic/rwmb_frontend_validate-and-update-_post-value

    im using the latest versions of all plugin extensions and have tested and checked my setup, no errors in php logs

    thanks

    Nick

    #48549
    PeterPeter
    Moderator

    Hello Nick,

    >> I assume the cleanup operation for the forms cloneable groups is not removed

    Yes, the cleanup process will be executed when saving the field value. If you set the post data when using the filter hook, you can check if a field value is not empty before setting the post data.

    I will also inform the development team to recheck this case and see if we can improve this in future updates.

    Thank you.

    #48560
    Nicholas CoxNicholas Cox
    Participant

    Im setting a few fields values, but the cloneable groups always has an empty value included, as i know this is hidden and user for the front end. But the rwmb_request()->set_post_data( $_POST ); is obviously setting the empty group as a value. So there is a conflict between the timing of the cleanup. But also the cleanup could also be changed to detect empty cloneable groups and remove them?

    #48653
    Nicholas CoxNicholas Cox
    Participant

    Hi Peter,

    any update on this?

    thanks

    Nick

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.