form not saving data

Support MB Frontend Submission form not saving dataResolved

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #41503
    Mark McLachlanMark McLachlan
    Participant

    I have a front end form built following your course to enable front end users to submit and update opening hours.
    I have also followed your instructions on how to build a block to use instead of a shortcode to insert the form into a page..

    The form via shortcode or block does not save data to the database. The form displays correctly.
    I have created a staging site and will email login details to [email protected] if you could have a look please.
    Thanks

    #41510
    PeterPeter
    Moderator

    Hello Mark,

    I do not receive your site information. Can you please resend it?

    Also, with the new version of Meta Box AIO 1.20.2 or MB Frontend Submission 4.3.0, you can use the block [Meta Box] Submission Form to create a frontend form with the Gutenberg block.

    #41514
    Mark McLachlanMark McLachlan
    Participant

    I have resent the information, thanks

    #41544
    Mark McLachlanMark McLachlan
    Participant

    The staging site I set up had a problem.
    I have a new one at
    https://www.staging42.boyneburnettinlandrailtrail.org.au/wp-login.php

    Once logged in to the backed you will see a custom post type

    Meta Box Forms

    I have added a post to that post type and published it. I had input the opening hours custom fields when writing the post.
    The post displays on the front end.
    I have added a menu item for it entitled "Form Display"
    The content and custom fields "days of the week" display in a list as Monday Tuesday etc.
    The opening times for each day as input into the custom fields do not.

    #41555
    PeterPeter
    Moderator

    Hello,

    I've tested to submit the frontend submission form on your site and see it works correctly. A new post of post type Form was created and saved field value. The field group is assigned to two CPTs so if you want to create a post for a specific CPT, please select it in the block settings. Screenshot https://monosnap.com/file/qER5EydWG5rNaVycFYYmld0TZjfkN4

    #41557
    Mark McLachlanMark McLachlan
    Participant

    This is becoming quite frustrating.
    Could you please address my question as above (19th April)

    #41569
    PeterPeter
    Moderator

    Hello,

    You are talking about the form not saving data, I see the data is still saved as well. Now you say the value does not display on the frontend. It depends on the code that you output the value.

    I see one issue is: the field ID when creating the field group has the prefix coho while the field ID in the View template on your site does not. That is why the code to get the field value is not working.

    #41575
    Mark McLachlanMark McLachlan
    Participant

    My apologies, as the form was not displaying as I expected, I assumed it was not saving to the database.

    I removed the prefix coho and updated it.

    Then dumped the table in the database.

    I duplicated the field group and published it after deleting the original.

    The field group is now only assigned to one CPT; Meta Box Form

    This left me with an empty table in the database.

    I then went to Meta Box Forms -> Add New and added the values to the post for the opening hours from the metabox at the bottom of the editor and published it.

    On the front end it did not display the hours which were input, rather just "Monday""Open All day" etc for each day of the week as per the screen shots I have emailed.

    I created a page "https://www.staging42.boyneburnettinlandrailtrail.org.au/opening-hours-test/" using the form block and input the values and submitted the form.

    It saved as "Pending" as per the settings. I published it and viewed on the front end.
    The result was the same just "Monday""Open All day" etc for each day of the week as per the screen shots.

    I have emailed a zip file with images of each step for both cases. They are sequential (A, B, C etc) so show in order, with the file name describing each.

    I have also included a .txt file with the full text from the two rows created in the database table.

    Thanks

    #41587
    PeterPeter
    Moderator

    Hello,

    I see the field values are saved to the custom table correctly. In the View code, the field "Choose an option" has the ID choose_an_option but you add the ID choose_an_options to get the value and it returns nothing.

    {% set options = post.choose_an_options.value %}

    #41589
    Mark McLachlanMark McLachlan
    Participant

    Thank you. Thank you.
    This might be something that needs to be fixed.
    I copied the View code from
    https://github.com/wpmetabox/tutorials/blob/master/showing-opening-hours-section-with-MB-Views/template.php

    It is also available at
    https://github.com/wpmetabox/tutorials/commit/5495291a395ab920ecd5e4daaacad9a82756cf75

    and a portion of the code with that error is also here
    https://metabox.io/display-restaurant-opening-hours-p1-meta-box-gutenberg/

    When I view the custom posts by going to
    All Meta Box Forms -> page form opening hours test -> View
    there is still an error of some type on the front end above where the "Opening Hours" display (correctly)

    There is the text "difference_between_weekdays_and_weekend1".
    when I "inspect" it I see it is wrapped in "pre" tags
    I have searched for where this is coming from.
    It does not appear to be in the View code or where the custom fields are written in the backend.

    "difference_between_weekdays_and_weekend" is only in the first options field as far as I can determine.

    #41590
    Mark McLachlanMark McLachlan
    Participant

    It was doing that because the following code is in the View code I copied.

    <pre>
    {{ mb.print_r(options) }}
    </pre>

    Remove that and all is fine.
    Thank you, I think all is now well.

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