• Resolved sp4rky35

    (@sp4rky35)


    Hello,

    I built a quite complex form with forminator (free atm, thinking about going to pro). It’s impressive … when it works ??

    Not sure why / how, but the stripe part stopped working at some point after I added some more field that are not involved at all in stripe.

    Basic thing in the form is:

    • 2 checkbox (1 & 3) with date based conditionnal. The date field will be hidden before going live but it allows testing. By default (until end of september) checkbox-3 is hidden, checkbox-1 is displayed
    • Some computation based on checkbox-1/3 values (you can see them in calculation-1, and some extra computation (which do not seems to be involved in my issue) on a calculation-2 fields
    • A total in a calculation-3 field, which just sums both others
    • Stripe use calculation-3 field as source

    At some point, stripe stopped working and displayed this well-known error. Some tests I did :

    • If I put a static value in stripe, it works
    • If i switch date to after Oct 1st, checkbox-1 disappear and checkbox-3 appear, i can check something in checkbox-3 and it works, which is did not expect as checkbox-1 and 3 are used in the very same way.
    • If i hide stripe, I get an error about checkbox-3 needing some values, EVEN when it’s hidden (while I don’t get the same error when checkbox-1 is hidden)

    Hope you can help with this ??

    The page I need help with: [log in to see the link]

Viewing 15 replies - 1 through 15 (of 24 total)
  • Thread Starter sp4rky35

    (@sp4rky35)

    The only difference I found between both in export is that both have a form_id but only checkbox-3 has a formid , not checkbox-1 , not sure why both exists. I’ve removed the formid from checkbox-3 and reimported, but does not solve the issue. The export linked here is the version *without* formid.

    • This reply was modified 1 year, 8 months ago by sp4rky35.
    Plugin Support Kris – WPMU DEV Support

    (@wpmudevsupport13)

    Hi @sp4rky35

    I hope you are doing well today.

    I pinged our SLS Team to review your query and form. We will post an update here as soon as more information is available.

    Kind Regards,
    Kris

    Thread Starter sp4rky35

    (@sp4rky35)

    Thank you Kris, will be happy to test anything if needed.

    Plugin Support Nithin – WPMU DEV Support

    (@wpmudevsupport11)

    Hi @sp4rky35,

    Please try the following snippet and check whether it works fine:

    <?php
    /**
     * Plugin Name: [Forminator Pro] - Fix can not submit on nest required fields
     * Description: [Forminator Pro] - Fix can not submit on nest required fields - 1153408161998285
     * Author: Thobk & Prashant @ WPMUDEV
     * Author URI: https://premium.wpmudev.org
     * License: GPLv2 or later
     */
    if ( ! defined( 'ABSPATH' ) ) {
    	exit;
    } elseif ( defined( 'WP_CLI' ) && WP_CLI ) {
    	return;
    }
    
    add_action( 'after_setup_theme', 'wpmudev_forminator_fix_can_not_submit_on_nest_required_fields_func', 100 );
    
    function wpmudev_forminator_fix_can_not_submit_on_nest_required_fields_func() {
    	if ( defined('FORMINATOR_PRO') && class_exists( 'Forminator' ) ) {
    		class WPMUDEV_FM_Fix_Sumit_Error_Required{
    			private $custom_form;
    			private $submitted_data;
    			public function __construct(){
    				add_filter( 'forminator_prepared_data', array( $this, 'save_submitted_data'), 10, 2 );
    				add_filter( 'forminator_custom_form_submit_errors', array( $this, 'custom_form_submit_errors' ), 10, 3 );
    			}
    
    			public function save_submitted_data( $submitted_data, $custom_form ){
    				if ( $submitted_data['form_id'] != 4726 ) { //Please change the form ID
    					return $submitted_data;
    				}
    
    				$this->custom_form = $custom_form;
    				$this->submitted_data = $submitted_data;
    				return $submitted_data;
    			}
    
    			public function custom_form_submit_errors( $submit_errors, $form_id, $field_data_array){
    				if( $submit_errors && $this->custom_form ){
    					$field_forms = array();
                        $fields_array = forminator_get_fields();
                        if ( ! empty( $fields_array ) ) {
                            foreach ( $fields_array as $key => $field ) {
                                $field_forms[ $field->type ] = $field;
                            }
                        }
    					foreach( $submit_errors as $error_id => $errors ){
    						foreach( $errors as $field_id => $msg ){
    							if( ! isset( $field_data_array[ $field_id ] ) ){
    								$field_array = $this->custom_form->get_field( $field_id, true );
    								$field_type     = isset( $field_array['type'] ) ? $field_array['type'] : '';
    								$form_field_obj = isset( $field_forms[ $field_type ] ) ? $field_forms[ $field_type ] : null;
    								if( ! empty( $field_array['conditions'] ) && $form_field_obj ){
    									if ( $form_field_obj->is_available( $field_array ) && ! $form_field_obj->is_hidden( $field_array ) ) {
    										unset( $submit_errors[ $error_id ][ $field_id ] );
    										if( empty( $submit_errors[ $error_id ] ) ){
    											unset( $submit_errors[ $error_id ] );
    										}
    									}
    								}
    							}
    						}
    					}
    				}
    				return $submit_errors;
    			}
    		}
    
    		$run = new WPMUDEV_FM_Fix_Sumit_Error_Required;
    			
    	}
    }

    In the above code 4726?should be changed to your forms ID.

    The snippet can be added as a mu-plugins. Please check this link on how to implement the above code as a mu-plugins:
    https://wpmudev.com/docs/using-wordpress/installing-wordpress-plugins/#installing-mu-plugins

    Once the code is added, you’ll also have to update the visibility condition on Stripe field side as shown in the following screenshot;

    Screenshot at 10:31:55.png

    Please do let us know how that goes.

    Best Regards,

    Nithin

    Thread Starter sp4rky35

    (@sp4rky35)

    Hi ! Thanks for answer.

    It’s better, but still not working. Better, because if I use the mail which hides the Stripe block, then it works (while I had an error on checkbox-3 before).

    But with stripe block (modified to use show/all instead of hide/any) used, I still get a “must be greater than or equal to 1”.

    I’ve tested it again, and it works if i put a date after Oct 1st (so checkbox-1 is hidden without anything selected, and checkbox-3 is show and I select something on it). I’d not expect that as they are both used in the very same way in form.

    Thread Starter sp4rky35

    (@sp4rky35)

    Another thing, I’m *sure* it did work that way (with both fields hidden / shown based on date) at some point. Not sure what made it not working.

    Looking at your code, it looks like it’s removing the underlying error (the requirement on checkbox-3) but not the stripe related error ?

    Plugin Support Williams – WPMU DEV Support

    (@wpmudev-support8)

    Hi @sp4rky35

    Thanks for response!

    I took another look at the form and I’m actually not sure if we are exploring the right direction here so I’d like to ask you for one more test (since I’m not that much familiar with the form itself and what it actually should do):

    – could you edit the form to set all the three calculation fields to be visible (they currently have “hidden” option enabled in settings)? This way you’ll see exactly what was calculated

    – and then test the form again filling it in the way that usually triggers an error?

    I’m wondering what will be the value of calculations and that is because when checking the form (with calculations set to not be hidden) I noticed that in some cases they seem to be at 0 while Stripe field is not hidden at the same time and also doesn’t have any additional plan configured to be conditionally used in such cases.

    So when calculations are at value of zero – the error in Stripe would be expected. And if so, the question and issue would then rather be “why calculations result in 0 value” and if it should be that way…

    I apologize if I’m asking something obvious to you but since the form is quite complex and we don’t really know much about the expected outcome of those calculations, Im just asking you to test it so we could confirm if the issue really is at Stripe or rather at calculations.

    Thank you in advance!
    Best regards,
    Adam

    Plugin Support Amin – WPMU DEV Support

    (@wpmudev-support2)

    Hello @sp4rky35 ,

    You did not respond to our questions for over a week now, so it looks like you no longer need our assistance.

    Feel free to re-open this topic if needed.

    Kind regards
    Kasia

    Thread Starter sp4rky35

    (@sp4rky35)

    Hello,

    sorry for delay, holiday time. The amount in calculation form is correct.

    I made a more easy to understand version which still triggers the bug. Basically :

    • Keep date before nov 1st, the checkbox-1 is seen and checkbox-3 and radio-13 are hidden > this triggers the “must be greater or equal” error
    • Switch date to nov 2 (or later), which hides checkbox-1 and shows checkbox-3 and radio-13, this works

    New form export is available here : https://www.breizhcoastswing.fr/Forminator-bug-event-form-export.txt

    Thread Starter sp4rky35

    (@sp4rky35)

    Strange thing I noticed. If i change the calculation to ({checkbox-1}/max({checkbox-1},1))48 + (max(0,{checkbox-1}-1))30, basically removing all links to checkbox-3 and radio-13 I *still* get the issue

    Thread Starter sp4rky35

    (@sp4rky35)

    So, made an even simpler version, still available at https://www.breizhcoastswing.fr/Forminator-bug-event-form-export.txt

    • computation field only includes checkbox-1
    • If is set a static value in computation field, it works

    Can’t see anything more I can do to help diagnose.

    Plugin Support Williams – WPMU DEV Support

    (@wpmudev-support8)

    Hey @sp4rky35

    Thanks for responses!

    I feel like I’m asking something “obvious” again but…

    I just imported your recent form to my test setup and noticed that the checkbox-1 remains hidden all the time, despite the date being correctly set to “before Oct 3rd” in date field. It didn’t make any difference if it was default date setting or if I selected date manually. So if the field is hidden, it’s value is always 0 and calculation – no matter if it’s simple or complex – would be affected by that.

    But once I simply removed visibility condition from checkbox-1 field, updated the form, re-added condition and updated the form again – it started working again.

    Is this something you can confirm? I’m asking because I’m not sure if that’s happening on your end too or it’s just some unexpected side-effect of export/import of the form.

    Also, could you share the original form again but via different file so we could import both again – the original one and the recently shared one?

    Kind regards,
    Adam

    Thread Starter sp4rky35

    (@sp4rky35)

    Thanks for your answer. I don’t see the same behavior, checkbox-1 is visible when the page first shows up. But if I remove the visibility condition on checkbox-1 then the submission works correctly !

    Looks like the client side logic and server side submission processing handle dates in a different way. The condition in the export is formatted based on my locale (it seems), as it appears as “2 Octobre 2023” in JSON export. This is likely not correctly evaluated when you import it on your test instance, which would causes the issue you see.

    Sounds like a good suspect for the issue ^^

    You can find fresh export of full form here : https://www.breizhcoastswing.fr/Forminator-template-event-form-export.txt (same URL as the first post but file has been refreshed)

    Thread Starter sp4rky35

    (@sp4rky35)

    Any news on this ? I’ve received an email from one of your tests ?? happy to help to test / diagnose if needed.

    Thread Starter sp4rky35

    (@sp4rky35)

    Not directly related (I guess) but I’ve seen that the stripe library used in forminator is a version from …2019 and 3 major release late.

    Does not give confidence in forminator , especially for a payment platform :/

Viewing 15 replies - 1 through 15 (of 24 total)
  • The topic ‘Another ““This value must be greater than or equal to 1” error with Stripe’ is closed to new replies.