Field pull custom table row data
Support › MB Frontend Submission › Field pull custom table row data
- This topic has 6 replies, 2 voices, and was last updated 4 months, 1 week ago by
Peter.
-
AuthorPosts
-
December 22, 2024 at 6:47 PM #47219
Nicholas Cox
ParticipantHi,
I have a select field in my form which stores a sql row id (for reference to a custom database table row). What is the best way to integrate related table data into the front end forms? I want each row column to be editable in the form (text fields etc) and when the form is submitted the data is sent back to the related custom table.
thanks
Nick
December 23, 2024 at 11:10 PM #47225Peter
ModeratorHello Nick,
If you want to use the existing table to store the field value, please follow the documentation https://docs.metabox.io/extensions/mb-custom-table/#using-existing-tables
notice the column name must match the field ID when you register/create the custom field.
December 24, 2024 at 5:35 PM #47228Nicholas Cox
ParticipantHi
No i am after saving different field data to separate tables in one form. So when each field passes validation it saves into a relational database table based on a set of validation rules.
December 24, 2024 at 7:31 PM #47230Nicholas Cox
ParticipantSo it would be cool to e.g. use a group field (with the name being the related database table name) and each child field being the column values (using any field type). This would allow flexibility to link multiple custom tables to one field group where we can automatically pull the data in on editing and posting/updating the row to the related database table.
My issue is that to achieve updating multiple related tables from one front end form is fine after submitting the form but when editing a form there is no easy way to prefill the form with the related table data (if exists).
December 25, 2024 at 10:02 PM #47236Peter
ModeratorHello Nick,
I'm afraid that it isn't possible. As I mentioned above, the column name in the custom table must match the field ID when you register/create the custom field. If you want to save data to separate custom table tables with one frontend form, you can create more field groups and add their IDs to the frontend shortcode.
[mb_frontend_form id='field-group_id_1,field-group_id_2,field-group_id_3' post_fields='title,content']
December 27, 2024 at 7:31 PM #47241Nicholas Cox
ParticipantAh ok thanks for clarifying
I will add the extra form field group to the shortcode.Just out of curiosity, if i have more than one custom table (each table being a field group) and they are all linked to the same post type will this cause any issues?
I also have some field groups which are custom models too, so just checking if the shortcode is the way to go for me.
December 28, 2024 at 9:39 PM #47252Peter
ModeratorHello,
If you have two or more custom tables for each field group, you can add all field group IDs to the frontend shortcode and save the field values to all custom tables when submitting or editing the post.
-
AuthorPosts
- You must be logged in to reply to this topic.