Unyson icon indicating copy to clipboard operation
Unyson copied to clipboard

Ajax based contact form

Open Ataurr opened this issue 11 years ago • 22 comments

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 :)

Ataurr avatar Mar 13 '15 10:03 Ataurr

:+1:

danyj avatar Mar 13 '15 10:03 danyj

like you, I don't see any notification after submitting contact form.

dylan-ngo11 avatar Mar 13 '15 11:03 dylan-ngo11

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.

Ataurr avatar Mar 13 '15 12:03 Ataurr

@xpeeder : textarea still work with 'col' width in my local site.

dylan-ngo11 avatar Mar 13 '15 12:03 dylan-ngo11

@duongancol but its not displayed full width in my localhost :( maybe i have replaced something.. i will try with fresh copy again. btw thanks :)

Ataurr avatar Mar 13 '15 12:03 Ataurr

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.

dylan-ngo11 avatar Mar 13 '15 12:03 dylan-ngo11

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.

ghost avatar Mar 13 '15 12:03 ghost

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

Ataurr avatar Mar 13 '15 19:03 Ataurr

@moldcraft it's better to iclude it in config : $cfg['ajax_submitable'] = true;

lgabeskiria avatar Mar 13 '15 20:03 lgabeskiria

@moldcraft I Have enqueue fw-form-helpers.js in theme. but still relaod the contact page. is there i am missing something ??

Thanks

Ataurr avatar Mar 25 '15 16:03 Ataurr

@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'
});

all options that you can overwrite

ghost avatar Mar 25 '15 17:03 ghost

@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

ghost avatar Mar 30 '15 13:03 ghost

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.

ghost avatar Mar 30 '15 13:03 ghost

Added info in docs http://manual.unyson.io/en/latest/helpers/php.html#fw-form-ajax-submit

ghost avatar Mar 30 '15 14:03 ghost

@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.

ghost avatar Mar 30 '15 15:03 ghost

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

Ataurr avatar Mar 30 '15 15:03 Ataurr

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).

ghost avatar Mar 30 '15 16:03 ghost

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

martinburdon avatar Apr 19 '15 19:04 martinburdon

Specify this parameter

fwForm.initAjaxSubmit({
    selector: 'form.fw_form_fw_form',
    ajaxUrl: '...'
});

ghost avatar Apr 19 '15 19:04 ghost

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.

martinburdon avatar Apr 20 '15 12:04 martinburdon