cForms Plugin Post-Processing - php

I have a cForms II contact form set up. It works perfectly if I just want the results emailed to myself (default behavior).
I now have a custom PHP file that will take the POST data from the form and submit it to an external database for me. However, when I set the Alternative Form Action page to this PHP page, clicking the Submit button just causes the form to hang.
How exactly do I pass the form data to my own PHP file while still keeping AJAX enabled (so form validation works)?
Cheers!

Ah, I figured it out!
To do post-processing, you don't redirect the form submission to your own file.
You simply modify the my_cforms_ajax_filter($params) function in the my-functions.php file (in your cForms directory).
This function is executed after form validation and before any data processing takes place (so you can intercept the form data).

Related

wordpress Gravity form data save to csv file on submit

I am using gravity form plugin on my WordPress website for client registration. Currently I am getting notification on email. I want to save the field data to csv/text file after hitting submit. Please someone suggest me how to do that.
Thanks :)
There has a hook gform_after_submission which executes after form submitted. You can add your own action where you will get all the form data and then you can create csv/text file there. Here is the documentation.
https://www.gravityhelp.com/documentation/article/gform_after_submission/
There has a hook gform_after_submission which executes after form submitted as You can add your own action/function where you will get all the form data and then you can create csv/text file there. Here is the documentation. https://www.gravityhelp.com/documentation/article/gform_after_submission/

Codeigniter submit form written in plain HTML

I'm playing for about 2 days now and can't make this out. I'm working in codeigniter 2.1.0. and I want to submit a form that is written in HTML. I don't want to use the CI form helper.
The reason is because I'm dynamically with JavaScript adding things in the form. When a user clicks an item then it's added to the form. Now when the user clicks the submit button all the items I added should be sent in a POST request, but my POST is totally empty.
Now I noticed that the POST only gets sent when I use form_input() from the CI form_helper.
Is it possible to just submit a normal plain HTML form without using the form helper?
Is it possible to just submit a normal plain HTML form without using the form helper?
Yes. The actual submit is totally independent to CI, just ensure you use the correct action URI of the form so that the correct controller action is called by the form submit post (I assume your form method is post) request.
You do not need to use the CI form_helper for the submit button. If you mock a form with these you will see that those just generate plain HTML and do nothing magically.

How to do File upload validation Server side without refreshing the Page?

I have created a script to Upload a file using PHP. I have also added file validation checking for File size & File type. But the scenario here is, the Form contain 10-12 Text boxes & a File upload box. So whenever someone fill the complete form & submit and they get File upload validation error, they get back to the Form with the validation error message. But the form gets empty as obviously it get posted on server side.
Is there any way to do the file upload validation without reloading/refreshing the page ?
I strongly recommend this plugin for file uploads. http://malsup.com/jquery/form/
It will allow you to verify the file, and if theres an error you can use json to determine whether the file is valid or not. I use it in all my projects, it's fantastic.
EDIT: Also it allows you to submit files without page refresh, which is the most important part.
You can use ajax:
1) when submit an ajax synchrounous call send the form content to the php server page
2) the php page validates the input
3) if return is "false" (error in validation) the javascript that executed the call sympli insert into the html of the page a proper message. The form stands filled in with the values of the user
You can use $_POST array for the posted values from the form . You should have write form method as POST
Also the same way you can ajax form this will not loose any of your data and page will not refresh as well

detect form submission finish with jquery

As we know you cannot create a file download via ajax.
you can however submit a form which will create a download prompt.
I am generating quite a big file when the users presses a button so I display a "please wait" style message.
My question is,
How can I detect when the form submission has finished, hence the dialog box has been shown?
(this is to hide the message)
Place a redirect when form submission is successful. If redirect will hit the file which browser can't display - it will start download.
In my case I return JavaScript code from form submit handler, which form widget eval()s. That code could be a redirect to the fine which was just produced by the back-end.
Maybe my blog post about AJAX Forms best practices will be helpful:
http://agiletoolkit.org/blog/forms/
If you wish to keep things simple, then:
add form.onSubmit handler, it should prevent default action, collect form data and send to server. You can use some ajax submission plugin for jQuery.
server should parse data, prepare file and send back the name of the file to browser.
your JS code gets executed when transfer is complete (callback) and does redirect to the file through document.location.
In Agile Toolkit it would be as simple as this:
$f=$p->add('MyForm');
if($f->isSubmitted()){
$f->js()->univ()->location(prepare_file($f->getAllData()))->execute();
}
Maybe you should try something like this
http://www.iamkumaran.com/xdownloader-a-flash-javascript-library/
See the demo how file download works and I hope it may help you.

Drupal form being rendered before submit action

I have a Drupal module page where I am populating a form with a drop-down that contains a list of available parts of a set of files that the user can upload. Once the user uploads a file of a certain type, it removes that option from the list, and when all the available files are uploaded the form will not be rendered.
The problem is that Drupal is drawing the form before it carries out the submit action, so it appears to the user that the operation didn't work until they reload the page.
What is the common way to deal with this? Setting form_state['redirect'] to go to the page doesn't seem to work.
You modify your form so that it saves some information on the state of the form. Then you add a new case to the beginning of the submit function that returns immediately if you're not done uploading all the files, and it will redraw the form.
function modulename_uploader_form(&$form_stuff=null) {
//the function that sets your form array
$stuff = (isset($form_stuff['values'])) ?
$form_stuff['storage']['done_uploading'] :
false; //if values isnt set, this is the first visit.
$form_stuff['storage']['done_uploading'] = done_uploading();
.... the rest of your form creation function.
function modulename_uploader_submit($form, &$form_stuff) {
if($form_stuff['storage']['done_uploading']) {
return;
}
... rest of the function
make sure to unset the storage variable when you're done processing the form. You can also google multi page forms in drupal.
Setting $form_state['redirect'] in your submit handler will just cause the form to reload, fresh, without the old data. It's a way of clearing out the form so that old values don't hang around as defaults.
You probably want to use $form_state['rebuild'], which gives your form-building functions an opportunity to rebuild the form's actual structure, adding more fields or removing options from other fields after the form submit handlers run.
This blog post has a rough tutorial on doing multiple-stage forms in D6, and the Drupal 5 to 6 upgrade docs on Drupal.org contain a useful overview of how $form_state works and what its various flags are for.
The problem is that Drupal is drawing the form before it carries out the submit action, so it appears to the user that the operation didn't work until they reload the page.
I cannot believe it. Are sure about that?

Categories