Ajax based contact form
Hi there. it will be great if contact form will be ajax based. so no need to refresh curent page after submit the contact form. also another issue i have found after submit the form. we dont receive any notification like "form submit successfully" after refresh the page
btw Thanks for this great framework :)
:+1:
like you, I don't see any notification after submitting contact form.
another issue i have found in text area. i just need little css to make it full width like others field. others filed work according to col width except text area field.
@xpeeder : textarea still work with 'col' width in my local site.
@duongancol but its not displayed full width in my localhost :( maybe i have replaced something.. i will try with fresh copy again. btw thanks :)
you can check the output in view.php(plugin/unyson/framework/extension/form/includes/option-types/form-builder/items/textare/) or you can override it by following the documentation.
You can use this script to make the form ajax submittable.
By default form errors are displayed by this code and (notifications) flash messages are displayed by this code.
I have in todo to improve form messages display, but haven't got there yet.
Hi @moldcraft you have added this in form ? it will be better if you include this directly in form. so everyone can use this without asking you how to make ajaxable form . Thank you
@moldcraft it's better to iclude it in config : $cfg['ajax_submitable'] = true;
@moldcraft I Have enqueue fw-form-helpers.js in theme. but still relaod the contact page. is there i am missing something ??
Thanks
@xpeeder just enqueue the script is not enought, you have to call the initialization script, here is an example
Try this (with all default options)
fwForm.initAjaxSubmit({
//selector: 'form[some-custom-attribute].or-some-class'
});
@xpeeder we dont receive any notification like "form submit successfully" after refresh the page
I tested it on one of wp default theme and the success message is showing
The success message is displayed through FW_Flash_Messages helper, please read this comment to understand how it works and how to display manually/better flash messages in your theme.
Added info in docs http://manual.unyson.io/en/latest/helpers/php.html#fw-form-ajax-submit
@levan1993 it's better to iclude it in config : $cfg['ajax_submitable'] = true;
I will not add such cfg.
There are something else I can do/help on this issue? I am thinking to close it.
Hi @moldcraft :) its work for me. but i thing if you include this on form that will be good for everyone. cause no one want refreshing the page.
Thank you
There are already themes that assume forms are not ajax submittable, so I can't change the default behavior (for e.g. our current Scratch Theme has some custom scripts for making ajax forms).
Hey @xpeeder, you said you had this working – wonder if you could help me out (or anyone else).
I'm enqueuing fw-form-helpers.js and running the init script:
fwForm.initAjaxSubmit({
selector: 'form.fw_form_fw_form'
});
But when I submit the form I get a console error that wp-admin/admin-ajax.php cannot be found. Did you or anyone else ever come up against this issue or know how to solve it?
Cheers
Thanks for the speedy reply @moldcraft.
I have added the line ajaxUrl: (typeof ajaxurl == 'undefined') ? '/wp-admin/admin-ajax.php' : ajaxurl but I still seem to get the error.