nazihheni / php-form-builder-class

Automatically exported from code.google.com/p/php-form-builder-class
GNU General Public License v3.0
0 stars 0 forks source link

Form Builder Class Submit Button - No Value #203

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Hi, I'm having problem with the submit button cuz when I try to click the it, 
it doesn't show its value in the $_POST.

I need it cuz there are instances that I would like the lines of code to run 
only when the user clicks the submit Button.

I'm not able to do that at the moment.

Original issue reported on code.google.com by afnav...@gmail.com on 12 Aug 2013 at 7:15

GoogleCodeExporter commented 8 years ago
It appears that a jQuery function disables all the submit buttons to prevent 
duplicate submissions.  I too would like to have multiple submit buttons on a 
form and then test the return $_POST to work out which one was submitted.  If 
you comment out the lines 307 - 312 in Form.php your submit variables are 
passed. 

Original comment by shamilto...@gmail.com on 27 Dec 2013 at 8:57

GoogleCodeExporter commented 8 years ago
Yeah that's why I was forced to create my own form class with common error 
checking. I didn't use google forms anymore. XDDDD

It's okay to not disable the the submit buttons cuz we can work around it by 
giving them unique names within the same page so it wouldn't be a problem. I 
don't know why they did that. I would have used google forms over my latest 
project but because of this I stopped. I hope google would resolve this one.

IMO, I think it would have been better if we include 1 file only in a project 
so that I don't have to do more things other than including 1 class file.

For example: it would have been better if it looks like this.

include "1class_file_for_a_form_class.php";

$form = new form();
$form->function_blah_blah(); //something like that... just saying :D

Original comment by afnav...@gmail.com on 28 Dec 2013 at 2:43

GoogleCodeExporter commented 8 years ago
I also have similar problem. Is there an easy way to know which button is 
pressed?
I have form with "New", "Save", "Delete", "Duplicate" buttons.

Original comment by patrick....@gmail.com on 18 Jun 2014 at 9:43

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Here the fix i created for the issue. (feel free to modify for your needs) It 
basically creates a hidden input with the value from the clicked button, and 
still allows the button to be disabled.

/*When the form is submitted, disable all submit buttons to prevent duplicate 
submissions.*/
        echo <<<JS
        jQuery("#$id input[type=submit]").click(function() {
            var submit_val = jQuery(this).val();
            var submit_name = jQuery(this).attr("name");
            jQuery('<input name="+submit_name+'" type="hidden" value="'+submit_val+'">').insertAfter(this);
        });

        jQuery("#$id").bind("submit", function() {
            jQuery(this).find("input[type=submit]").attr("disabled", "disabled"); 
        });
JS;

Original comment by jhardgra...@gmail.com on 26 Jun 2014 at 6:00

GoogleCodeExporter commented 8 years ago
Notice: Undefined index: name in C:\xampp\htdocs\afnokaam\submit.php on line 4

Original comment by rudrapa...@gmail.com on 24 Dec 2014 at 2:17