[MB Frontend Submission] Multiple IDs in one form, possible?

Support MB Frontend Submission [MB Frontend Submission] Multiple IDs in one form, possible?

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #5831
    YasinYasin
    Participant

    Hello

    I am trying to create a realestate submission form,

    I have some ids like,

    estate_indoor_options (multiple_selectbox)
    estate_outdoor_options (multiple_selectbox)
    estate_comfort_options (multiple_selectbox)
    estate_location ( map )

    If i create multiple forms with multiple shortcodes like

    [mb_frontend_form id="estate_indoor_options"]
    [mb_frontend_form id="estate_outdoor_options"]
    [mb_frontend_form id="estate_comfort_options"]
    [mb_frontend_form id="estate_location"]

    there are 4 submission forms on one page. But i want to the shortcode to render multiple ids in one form. Because if there is 4 forms , each of them needs seperate submission.

    Is there a way to make include multiple ids in shortcode?

    #5840
    Anh TranAnh Tran
    Keymaster

    Why do you need 4 meta boxes / forms? Is it just easier to create 1 meta box / form with all the fields? You can use the heading, divider fields to keep them separated. Or use custom_html field to insert custom HTML between them.

    I think it's better than creating 4 forms (and the shortcode can't handle multiple IDs at the moment).

    #5848
    YasinYasin
    Participant

    Hello

    Yes its so simple when they are all in one id but, i am looping a lot of foreach for RWMB_Core::get_meta_boxes(); to get both values and keys in the frontend to make it easy to print fields.

    Now i am also started to use same foreach to build a submission form and its working without any problem. However i have different issue hope you can guide me.

    I have a multiple checkbox field and the values of checkboxes are 1,2,3,4,5,6,7,8,9,10

    the meta_key is shown in fields are like this

    <input value="1" type="checkbox" size="30" class="rwmb-checkbox_list " name="estate_purpose[]">

    However when i am inserting post i couldnot find a way to insert estate_purpose[] values.

    Here are some tries:

    [estate_purpose] => Array
            (
                [0] => 9,  //(id)
                [1] => 10, //(id)
            )
    [estate_purpose] => Array
            (
                [9] //(id) => 1,
                [10]//(id) => 1,
            )
    [estate_purpose] => Array
            (
                [9] //(id) => on,
                [10]//(id) => on,
            )

    none of them worked. How can i insert multiple checkbox fields into the post? I mean how the array must be built?

    Thanks.

    #5850
    Anh TranAnh Tran
    Keymaster

    If you want to insert values for checkbox_list, you should insert each value in 1 meta, like this:

    add_post_meta( $post_id, $key, 1, false );
    add_post_meta( $post_id, $key, 2, false );

    Note to set the last parameter false. It makes we can insert multiple values in multiple rows for the post.

    #5853
    YasinYasin
    Participant

    Thanks for guide, it worked!

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘[MB Frontend Submission] Multiple IDs in one form, possible?’ is closed to new replies.