From my reading, the editor page of a post is wrapped in a form tag meaning a standard HTML form won't work within a Meta Box.
What I'm trying to achieve is a meta box with two fields e.g. Name & Email and a button. When the button is pressed, a POST request will be sent. I can't use AJAX in this instance.
I can render the meta box and a button, along with a simple href link, but is there a way to generate an HTML form, or an alternative method, to replicate POST functionality?
Example Code, I've removed some of the hooks for brevity.
function lx_add_paperwork_meta_box() {
add_meta_box(
'my_meta_location',
'Generate Paperwork',
'display_generate_button',
'document',
'side',
'default'
);
}
function display_generate_button() {
output_generate_button( __( 'Create Paperwork', 'my-invoices' ), 0, 'paperwork-generate', array( 'class="button"' ) );
}
function output_generate_button( $title = 'Create', $order_id = 0, $action = 'none',
$attributes = array() ) {
$url = wp_nonce_url( add_query_arg( array(
'post' => $order_id,
'action' => 'edit',
'paperwork_action' => $action,
), admin_url( 'post.php' ) ), $action, 'nonce' );
$attr_title = $title;
printf( '<a href="%1$s" title="%2$s" %3$s>%4$s</a>', $url, $attr_title, join( ' ', $attributes ), $title );
}