Support Forum
Support › MB Frontend Submission › Front End Form and Custom Model - Not Saving Data To Custom TableResolved
Hi
I have created a custom model for the first time and I have successfully setup the table etc but having trouble with using the front end form shortcode. The form submits successfully but no data is passed to the custom table in the database?
I also tested the wp-admin form in the backend where the custom table model is displayed and this form posts successfully to the database table (so only the front end shortcode is not working) any ideas? i have also tested with ajax enabled and disabled, no luck there. Also no PHP errors.
Custom table model
add_action( 'init', 'dc_product_comments_table' );
function dc_product_comments_table() {
global $wpdb;
$tablename = $wpdb->prefix . 'dc_product_comments';
MB_Custom_Table_API::create(
$tablename, // Table name.
[
'product_id' => 'BIGINT(20) NOT NULL',
'comment_parent' => 'BIGINT(20) NOT NULL',
'comment_author_email' => 'VARCHAR(100) NOT NULL',
'comment_author_ip' => 'VARCHAR(100) NOT NULL',
'comment_date' => 'DATETIME NOT NULL',
'comment_content' => 'TEXT NOT NULL',
'user_id' => 'BIGINT(20) NOT NULL',
],
['product_id', 'user_id'], // List of index keys.
true // THIS: Must be true for models.
);
}
custom fields (just added in one field for testing purposes)
add_filter( 'rwmb_meta_boxes', 'dc_product_comments_register_fields' );
function dc_product_comments_register_fields( $meta_boxes ) {
//create fields and link them to the cutom table.
global $wpdb;
$tablename = $wpdb->prefix . 'dc_product_comments';
$meta_boxes[] = [
'title' => 'Product Comments',
'models' => ['dc-product-comments'],
'id' => 'dc-product-comments',
'storage_type' => 'custom_table', // Must be 'custom_table'
'table' => $tablename,
'fields' => [
[
'type' => 'textarea',
'name' => 'Comment',
'id' => 'comment_content',
'required' => true,
'admin_columns' => [
'position' => 'after id',
],
],
],
];
return $meta_boxes;
}
front end shortcode
[mb_frontend_form id="dc-product-comments" confirmation="posted" ajax="true"]
Hi,
The extension MB Frontend Submission does not support creating the custom model on the frontend. I will inform the development team to explore the possibility.
Hi
Ah ok I assumed this would have worked the same way as posts with front end submission.
My website users use front end forms only. Do you have a public roadmap for this if it gets added? as my project timeframe is coming to an end.
thanks
I just tried this myself to see if this feature is supported yet and it still looks like its not possible. I would like to add my vote for this feature request.