This worked for me:
In the template file (used with that existing form), before the get_header();
call/line, add this code:
global $my_dates_MB;
// If you changed the meta box ID (i.e. mydates), change it also below.
add_filter( 'rwmb_show_mydates', '__return_false' );
$meta_boxes = get_dates( [] );
$my_dates_MB = rwmb_get_meta_box( $meta_boxes[0] );
if ( isset( $_POST['my_dates_post_ID'] ) ) {
// Save the meta data.
$my_dates_MB->save_post( $_POST['my_dates_post_ID'] );
}
// Enqueue styles and scripts.
add_action( 'wp_enqueue_scripts', [ $my_dates_MB, 'enqueue' ] );
//$my_dates_MB->enqueue();
Then replace this:
$mydates = if(isset($_POST['prefix-mydates'])) echo $_POST['prefix-mydates'];
<fieldset>
<input type="text" value="" id="prefix-mydates" class="rwmb-date hasDatepicker" size="60" tabindex="20" name="prefix-mydates">
</fieldset>
..with this:
(UPDATED; May 02 2018)
<?php
global $my_dates_MB;
// Get the current post ID.
$post_id = get_the_ID();
// Set the post ID for the "meta box".
$my_dates_MB->set_object_id( $post_id );
// Show the meta box.
$my_dates_MB->show();
?>
<input type="hidden" name="my_dates_post_ID" value="<?php echo $post_id; ?>" />
That will print the whole “meta box” as defined in your custom get_dates()
function (btw, change its name to something unique), but that should not be an issue since the meta box has just one field.
You’d get something like this: (not including the “Submit” button)