Field pull custom table row data

Support MB Frontend Submission Field pull custom table row data

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #47219
    Nicholas CoxNicholas Cox
    Participant

    Hi,

    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

    #47225
    PeterPeter
    Moderator

    Hello 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.

    #47228
    Nicholas CoxNicholas Cox
    Participant

    Hi

    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.

    #47230
    Nicholas CoxNicholas Cox
    Participant

    So 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).

    #47236
    PeterPeter
    Moderator

    Hello 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']

    #47241
    Nicholas CoxNicholas Cox
    Participant

    Ah 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.

    #47252
    PeterPeter
    Moderator

    Hello,

    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.

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.