I just have one custom field (from metabox.io) that I need added to the front end of an existing form. Can someone just clarify the steps. I tried following this tutorial: https://voodoopress.com/add-a-meta-box-to-use-custom-fields-on-front-end-post-form/ but am confused with the steps such as adding the input fields into an array. Do we only need to do this if we're creating a form from scratch? Will this array already exist if I'm using an existing form?
I just need someone to clarify how to get the values of the metabox into an input field on the form and saving the data if the user edits the page and also if they submit.
**UPDATE
Admin code:
function get_dates( $meta_boxes ) {
$prefix = 'prefix-';
$meta_boxes[] = array(
'id' => 'mydates',
'title' => esc_html__( 'Dates Available', 'mydates' ),
'post_types' => array( 'listing', 'page' ),
'context' => 'side',
'priority' => 'low',
'autosave' => false,
'fields' => array(
array(
'id' => $prefix . 'mydates',
'type' => 'date',
'name' => esc_html__( 'Date Picker', 'mydates' ),
'desc' => esc_html__( 'Select multiple dates', 'mydates' ),
'clone' => true,
'sort_clone' => true,
),
),
);
return $meta_boxes;
}
add_filter( 'rwmb_meta_boxes', 'get_dates' );
Front end form (editing and submitting the form)
$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>
rwmb_meta()
to display the field value.