Support Forum
Support › MB Frontend Submission › Submit Button Issue
Hello,
I noticed that usually I have to click twice on the submit button to trigger form submission.
Additionally, in some browsers (e.g., Firefox), submit buton doesn't work at all.
Hello,
Please share the page that has the frontend submission form on your site, I will take a closer look.
Besides that, do you use any custom code to customize the form? You can try to create a new page and put the simple shortcode to the page content [mb_frontend_form post_fields='title,content']
and recheck the issue on this page.
Hi, I am not able to share the website, which is offline.
I create the form with:
[mb_frontend_form id="field_group_1,field_group_2,field_group_3" edit="true" post_fields="" post_type="custom_post_type" submit_button="Save"]
Then each field group is made with rwmb_meta_boxes
filter.
I noticed the issue exists when I edit existing post. Empty form triggers submission without the issue.
Hello,
I do not see that issue on my local site, here is the screen record https://imgur.com/4tzmIvH
After the first submit click, the post is created as well. The form is still displayed because the attribute edit
is set to true
.
I tried to disable other plugins and switch to default theme, but no change.
I also checked for any errors on form submission, but receiving no errors.
Currently I use tabs to preset fields, I tried to check for issues with tabs disabled, but still the problem exists.
Okay, I think I have found the reason why the form submission isn't triggered as expected.
It's the validation
part of the meta_boxes
array. Removing validation
key restored normal form submission. I haven't yet made any further tests, but at least there's a starting point, and maybe it might help you pointing out a solution? I will carry on checking it anyway.
Digging deeper and I could narrow down the issue reason to the remote
parameter of the rules
key.
Next, different browsers behave different way, depending on how many rules within validation
key have remote
parameter set up:
1. In Brave: When I have only single field with validation
> rules
> field_name
> remote
set to something like 'remote' => admin_url( 'admin-ajax.php?action=h29dk' )
the form works. However, adding second remote rule for another field (with different action name) causes the issue with the form submission. Two rules, one with remote parameter and one without, don't cause the issue.
2. Firefox: The issue exists already with only single rule with remote
parameter.
Would be grateful for further tips on how this could be fixed in order to keep remote validation.
Hello,
So please share the PHP code that creates the meta box on your site. I will check it on my demo site.
Now, the problem seems to be with the callback to the ajax request.
I have the following callback function set in 'remote' => admin_url( 'admin-ajax.php?action=test_request' )
:
function test_function() {
$title = $_GET['post_title'];
if ( 65 >= mb_strlen( $title, 'UTF-8' ) ) {
echo 'true';
} else {
echo 'false';
}
die;
}
add_action( 'wp_ajax_test_request', 'test_function' );
Testing it in Firefox gives the following results:
1. When I edit the post and click on Save without clicking inside any text fields the form submission doesn't trigger.
2. When I edit the post and before I click Save I click inside the title field (this field undergoes above validation), the form triggers submission. The title's validation works upon clicking inside the filed as expected (if the title is longer than 65 characters the validation fails, otherwise, the field is valid and the error message disappears).
If you still prefer to have the code I use to create the metabox, can we share it securely?
Hello,
On my demo site, with Firefox, I need to click Submit button twice in order to submit the post and the validation also does not work. But it works properly when testing with Chrome.
I'm escalating this issue to the development team to check this.
Thanks for your details.
Thanks, hopefully this can be fixed.
Indeed Chrome seems to handle form submission with fewer problems than Brave and Firefox, according to the users of my website who were testing it in this browser, but Brave and Firefox also show differences in this matter.
Looking forward to hearing from you.
Hi, any chance this issue can be solved soon?
Hello guys, will the issue be addressed at all, or we should seek another solution?
Hello,
The development team is checking the issue. I will get back to you soon.