Frontend form populating with page (not post)
Support › MB Frontend Submission › Frontend form populating with page (not post)
- This topic has 2 replies, 2 voices, and was last updated 1 year ago by
Peter.
-
AuthorPosts
-
April 4, 2024 at 10:49 PM #45146
Yasmine
ParticipantI have a long form to edit my
research
custom post type. This is the beginning:<?php add_filter( 'rwmb_meta_boxes', 'your_prefix_function_name' ); function your_prefix_function_name( $meta_boxes ) { $prefix = ''; $meta_boxes[] = [ 'title' => __( 'Academic: Research Summary', 'your-text-domain' ), 'id' => 'academic-research-summary', 'post_types' => ['research'], 'tabs' => [ 'page_1' => [ 'label' => 'One / Multiple', 'icon' => '', ], 'page_2' => [ 'label' => 'Title', 'icon' => '', ], 'page_3' => [ 'label' => 'Focus', 'icon' => '', ], 'page_4' => [ 'label' => 'Topic', 'icon' => '', ], 'page_5' => [ 'label' => 'Country', 'icon' => '', ], 'page_6' => [ 'label' => 'Purpose', 'icon' => '', ], 'page_7' => [ 'label' => 'Findings', 'icon' => '', ], 'page_8' => [ 'label' => 'Audience', 'icon' => '', ], 'page_9' => [ 'label' => 'Sector', 'icon' => '', ], 'page_10' => [ 'label' => 'SDG', 'icon' => '', ], 'page_11' => [ 'label' => 'Recommendations', 'icon' => '', ], 'page_12' => [ 'label' => 'Insights', 'icon' => '', ], 'page_13' => [ 'label' => 'Reference', 'icon' => '', ], 'page_14' => [ 'label' => 'Extra (question)', 'icon' => '', ], 'page_15' => [ 'label' => 'Extra (response)', 'icon' => '', ], 'page_16' => [ 'label' => 'Additional (question)', 'icon' => '', ], 'page_17' => [ 'label' => 'Additional (response)', 'icon' => '', ], 'page_18' => [ 'label' => 'Glossary (question)', 'icon' => '', ], 'page_19' => [ 'label' => 'Glossary (response)', 'icon' => '', ], 'page_20' => [ 'label' => 'Representation - representative', 'icon' => '', ], 'page_21' => [ 'label' => 'Respresentation - language', 'icon' => '', ], 'page_22' => [ 'label' => 'Tags', 'icon' => '', ], 'page_23' => [ 'label' => 'Hidden', 'icon' => '', ], ], 'fields' => [ [ 'type' => 'heading', 'name' => __( 'Getting started', 'your-text-domain' ), 'class' => 'rs_p1 header-class', 'tab' => 'page_1', ], [ 'type' => 'custom_html', 'std' => __( 'Will your summary be based on a single research paper or multiple papers?', 'your-text-domain' ), 'class' => 'rs_p1 instruction-class', 'tab' => 'page_1', ], [ 'name' => __( 'Single or Multiple papers', 'your-text-domain' ), 'id' => $prefix . 'academicsingle_multiple', 'type' => 'radio', 'options' => [ 1 => __( 'One', 'your-text-domain' ), 2 => __( 'Multiple', 'your-text-domain' ), ], 'std' => 1, 'class' => 'rs_p1', 'inline' => true, 'tab' => 'page_1', ], [ 'id' => $prefix . 'rs_p1_next_btn', 'type' => 'button', 'std' => __( 'OK <i class="fas fa-check"></i>', 'your-text-domain' ), 'columns' => 6, 'save_field' => false, 'tab' => 'page_1', 'attributes' => [ 'data-target' => 'page_2', 'class' => ' rs_p1 continue-btn' ] ], [ 'type' => 'heading', 'name' => __( 'Title <span style="color:#E09590">* </span>', 'your-text-domain' ), 'class' => 'rs_p2 heading-class', 'tab' => 'page_2', ], [ 'type' => 'custom_html', 'std' => __( 'Before we start, make a title for your group of papers', 'your-text-domain' ), 'class' => 'rs_p2 instruction-class', 'visible' => [ 'when' => [['academicsingle_multiple', '=', 2]], 'relation' => 'or', ], 'tab' => 'page_2', ], [ 'type' => 'custom_html', 'std' => __( 'Before we start, what is the title of your paper?', 'your-text-domain' ), 'class' => 'rs_p2 instruction-class', 'visible' => [ 'when' => [['academicsingle_multiple', '!=', 2]], 'relation' => 'or', ], 'tab' => 'page_2', ], [ 'name' => __( 'Title', 'your-text-domain' ), 'id' => 'post_title', 'type' => 'text', 'placeholder' => __( 'Type your summary title here..', 'your-text-domain' ), 'class' => 'rs_p2', 'std' => '', 'tab' => 'page_2', ],
But I have the issue that it is editing the page it is on and not the custom post type. The title field populates with the page title. This is my shortcode [mb_frontend_form id="academic-research-summary" edit="true" post_type="research" confirmation="Saved" post_id="current"]
why is it not working with my custom post type?
April 4, 2024 at 10:57 PM #45147Yasmine
ParticipantEvery time I finally give up and reach out for support, after sending the support ticket I instantly figure it out. It was because of this - post_id="current"- in the shortcode, right?
I was wanting to use the same form to create new and for editing posts later. Is that not possible?
April 6, 2024 at 8:50 AM #45154Peter
ModeratorHello,
It isn't possible to use one frontend shortcode to edit the current post and create new one. You can try to use two frontend shortcodes:
- On the post template: use the attributepost_id="current"
to edit the current post.
- On the separate page: remove that attribute to submit a new post. -
AuthorPosts
- You must be logged in to reply to this topic.