Support » Plugin: Forminator - Contact Form, Payment Form & Custom Form Builder » Condition on the result of a calculation

  • Resolved ceralis

    (@ceralis)


    Hello

    I am creating a form for direct meat sales.
    The sale is made in the form of packages in the number of 5
    For 3 of them, you just have to enter the number of packages you want
    For 2 others, you must indicate the number of packages but also choose from 3 items: the customer must distribute 6kg over 3 different items
    The form must therefore block the sending if the total of the three choices does not add up to 6kg

    Is it possible to display a message saying: the total is not 6 (for example using a calculation field)?
    And therefore prevent the customer from going further

    I have tried the method of hiding the send button if the total is not 6 and it works. Problem if the customer simply wants another package, the send button does not appear …

    What method do you suggest to me?

    Thank you for your help

    Freddy

Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    HI @ceralis

    I hope you are doing well.

    A workaround would be using the number field to limit based on the package:

    https://monosnap.com/file/lcGrB0NiimAAGYyKEu52ldN1zQDJHJ

    However, the Forminator has some custom filter for custom errors, unfortunately, this won’t work using calculation once the field is read-only and won’t pass on the $_POST.

    But you can add two number fields to control and quantity of items and create your conditional.

    A simple example using two number fields.

    
    <?php
    
    /**
    * Create a custom error message
    */
    
    add_filter('forminator_custom_form_submit_errors', 'my_custom_form_validation', 10, 3);
    
    function my_custom_form_validation($submit_errors, $form_id, $field_data_array) {
    
       // Skip if is not the correct form
      if((int)$form_id !== 49){
        return;
      }
      $num1 = (int) $_POST['number-1'];
      $num2 = (int) $_POST['number-2'];
    
      // Custom error if ID already submited
      if($num1 + $num2 > 6){
          $submit_errors[][ 'number-1'] = __( 'The Total Can Not Be More Than 6Kg, Please Enter a Different Number' );
          $submit_errors[][ 'number-2'] = __( 'The Total Can Not Be More Than 6Kg, Please Enter a Different Number' );
      }
    
      // Always return $submit_errors
      return $submit_errors;
    
    }

    Replace the “49” using your field ID, and add the code as a mu-plugin:
    https://premium.wpmudev.org/docs/using-wordpress/installing-wordpress-plugins/#installing-mu-plugins

    Let us know if you have any further question on this.
    Best Regards
    Patrick Freitas

    Thread Starter ceralis

    (@ceralis)

    Excellent !!
    Thank you very much it works the way I want it to.
    That’s great

    Thread Starter ceralis

    (@ceralis)

    Just a detail

    When there is an error on the 1st package, the page scroll is positioned on the fields in error

    When there is an error on the second package just below, the page scroll is positioned at the top of my page

    Thank you for your help

    Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @ceralis

    I hope you are doing well.

    It should go to the top of the form in both situations because the conditional trigger the error on num1 & num2

      $submit_errors[][ 'number-1'] = __( 'The Total Can Not Be More Than 6Kg, Please Enter a Different Number' );
          $submit_errors[][ 'number-2'] = __( 'The Total Can Not Be More Than 6Kg, Please Enter a Different Number' );

    The conditional and number of fields need to be extended depending on the form.

    Could you please export your form and we can take a closer look?

    https://premium.wpmudev.org/docs/wpmu-dev-plugins/forminator/#import-export

    Upload it on the Google drive and share the link.

    Best Regards
    Patrick Freitas

    Thread Starter ceralis

    (@ceralis)

    Hi

    Form export

    {“type”:”form”,”data”:{“fields”:[{“id”:”section-1″,”element_id”:”section-1″,”form_id”:”wrapper-5318-5795″,”type”:”section”,”options”:[],”cols”:12,”conditions”:[],”wrapper_id”:”wrapper-5318-5795″,”section_title”:”Colis tradition : 14€/kg”,”cform-section-border-style”:”none”},{“id”:”html-1″,”element_id”:”html-1″,”form_id”:”wrapper-639-4724″,”type”:”html”,”options”:[],”cols”:6,”conditions”:[],”wrapper_id”:”wrapper-639-4724″,”field_label”:””,”variations”:”

      \n

    • 6 kg 500 de pièces à griller (entrecôte, tournedos, rôti, côte de bœuf, faux-filet…)
    • \n

    • 5 kg 500 de viande à mijoter (jarret, bourguignon, plat de côte)
    • \n

    • Poids total du colis : 12 kg env.
    • \n

    “,”custom-class”:””},{“id”:”number-1″,”element_id”:”number-1″,”form_id”:”wrapper-639-4724″,”type”:”number”,”options”:[],”cols”:6,”conditions”:[],”wrapper_id”:”wrapper-639-4724″,”calculations”:”true”,”limit_min”:1,”limit_max”:150,”field_label”:”Nombre de Colis tradition”,”placeholder”:”Par exemple : 10″,”description”:””},{“id”:”section-2″,”element_id”:”section-2″,”form_id”:”wrapper-6884-9330″,”type”:”section”,”options”:[],”cols”:12,”conditions”:[],”wrapper_id”:”wrapper-6884-9330″,”section_title”:”Colis découverte : 15,50€/Kg”,”cform-section-border-style”:”none”,”formid”:”wrapper-4875-6949″},{“id”:”html-3″,”element_id”:”html-3″,”form_id”:”wrapper-6353-9273″,”type”:”html”,”options”:[],”cols”:6,”conditions”:[],”wrapper_id”:”wrapper-6353-9273″,”field_label”:””,”variations”:”

      \n

    • 3 kg de pièces à griller (entrecôte : steak, rôti, …)
    • \n

    • 1 kg de bourguignon
    • \n

    • 1 kg de steak haché
    • \n

    • 1 kg de saucisse
    • \n

    • Poids total du colis : 6 kg env.
    • \n

    “,”custom-class”:””,”formid”:”wrapper-1293-6365″},{“id”:”number-8″,”element_id”:”number-8″,”form_id”:”wrapper-6353-9273″,”type”:”number”,”options”:[],”cols”:6,”conditions”:[],”wrapper_id”:”wrapper-6353-9273″,”calculations”:”true”,”limit_min”:1,”limit_max”:150,”field_label”:”Nombre de Colis découverte”,”placeholder”:”Par exemple : 10″,”description”:””,”formid”:”wrapper-8482-9288″},{“id”:”section-3″,”element_id”:”section-3″,”form_id”:”wrapper-9988-9994″,”type”:”section”,”options”:[],”cols”:12,”conditions”:[],”wrapper_id”:”wrapper-9988-9994″,”section_title”:”Colis Veau de lait : 15.50€/ Kg”,”cform-section-border-style”:”none”,”formid”:”wrapper-2157-6460″},{“id”:”html-4″,”element_id”:”html-4″,”form_id”:”wrapper-4537-7302″,”type”:”html”,”options”:[],”cols”:6,”conditions”:[],”wrapper_id”:”wrapper-4537-7302″,”field_label”:””,”variations”:”

      \n

    • 1.5 kg de rôti
    • \n

    • 1.3 kg d’escalope
    • \n

    • 1.3 kg de côte
    • \n

    • 2.7 kg de sauté de veau, osso bucco, tendron.
    • \n

    • 0.2 kg de paupiette
    • \n

    • Poids total du colis : 7 kg env.
    • \n

    “,”custom-class”:””,”formid”:”wrapper-8129-3333″},{“id”:”number-3″,”element_id”:”number-3″,”form_id”:”wrapper-4537-7302″,”type”:”number”,”options”:[],”cols”:6,”conditions”:[],”wrapper_id”:”wrapper-4537-7302″,”calculations”:”true”,”limit_min”:1,”limit_max”:150,”field_label”:”Nombre de Colis veau de lait”,”placeholder”:”Par exemple : 10″,”description”:””,”formid”:”wrapper-9851-2270″},{“id”:”section-4″,”element_id”:”section-4″,”form_id”:”wrapper-5720-9029″,”type”:”section”,”options”:[],”cols”:12,”conditions”:[],”wrapper_id”:”wrapper-5720-9029″,”section_title”:”Colis grillade : 15€/Kg”,”cform-section-border-style”:”none”,”formid”:”wrapper-3638-9068″},{“id”:”html-5″,”element_id”:”html-5″,”form_id”:”wrapper-9499-7633″,”type”:”html”,”options”:[],”cols”:6,”conditions”:[],”wrapper_id”:”wrapper-9499-7633″,”field_label”:””,”variations”:”

      \n

    • 6 kg de pièces à griller (entrecôte, tournedos, rôti…)
    • \n

    • 6 kg  de saucisses de bœuf et/ou steaks hachés et/ou merguez
    • \n

    • Poids total du colis : 12 Kg env.
    • \n

    “,”custom-class”:””,”formid”:”wrapper-2554-4561″},{“id”:”number-4″,”element_id”:”number-4″,”form_id”:”wrapper-9499-7633″,”type”:”number”,”options”:[],”cols”:6,”conditions”:[],”wrapper_id”:”wrapper-9499-7633″,”calculations”:”true”,”limit_min”:1,”limit_max”:150,”field_label”:”Nombre de Colis grillades (12kg environ) : 15€/kg”,”placeholder”:”Par exemple : 10″,”description”:””,”formid”:”wrapper-5888-1310″},{“id”:”number-6″,”element_id”:”number-6″,”form_id”:”wrapper-3864-2167″,”type”:”number”,”options”:[],”cols”:3,”conditions”:[{“element_id”:”number-4″,”rule”:”is_great”,”value”:”0″}],”wrapper_id”:”wrapper-3864-2167″,”calculations”:”true”,”limit_min”:”0″,”limit_max”:”6″,”field_label”:”kg de steack haché”,”placeholder”:”Par exemple : 3″,”formid”:”wrapper-9599-2554″,”required”:true,”default_value”:””,”required_message”:”Veuillez saisir une valeur entre 0 et 6″},{“id”:”number-7″,”element_id”:”number-7″,”form_id”:”wrapper-3864-2167″,”type”:”number”,”options”:[],”cols”:3,”conditions”:[{“element_id”:”number-4″,”rule”:”is_great”,”value”:”0″}],”wrapper_id”:”wrapper-3864-2167″,”calculations”:”true”,”limit_min”:”0″,”limit_max”:”6″,”field_label”:”kg de merguez”,”placeholder”:”Par exemple : 1″,”formid”:”wrapper-847-9030″,”required”:true,”default_value”:””,”required_message”:”Veuillez saisir une valeur entre 0 et 6″},{“id”:”number-5″,”element_id”:”number-5″,”form_id”:”wrapper-3864-2167″,”type”:”number”,”options”:[],”cols”:3,”conditions”:[{“element_id”:”number-4″,”rule”:”is_great”,”value”:”0″}],”wrapper_id”:”wrapper-3864-2167″,”calculations”:”true”,”limit_min”:”0″,”limit_max”:”6″,”field_label”:”kg de saucisses”,”placeholder”:”Par exemple : 2″,”required”:true,”default_value”:””,”required_message”:”Veuillez saisir une valeur entre 0 et 6″},{“id”:”calculation-1″,”element_id”:”calculation-1″,”form_id”:”wrapper-3864-2167″,”type”:”calculation”,”options”:[],”cols”:3,”conditions”:[{“element_id”:”number-4″,”rule”:”is_great”,”value”:”0″}],”wrapper_id”:”wrapper-3864-2167″,”field_label”:”Total kg”,”placeholder”:”Par exemple : Valeur calculée”,”hidden”:false,”formula”:”{number-6}+{number-7}+{number-5}”,”precision”:”0″,”suffix”:”kg”},{“id”:”section-5″,”element_id”:”section-5″,”form_id”:”wrapper-3635-623″,”type”:”section”,”options”:[],”cols”:12,”conditions”:[],”wrapper_id”:”wrapper-3635-623″,”section_title”:”Colis mixte : 14,50€/Kg”,”cform-section-border-style”:”none”,”formid”:”wrapper-1443-9791″},{“id”:”html-6″,”element_id”:”html-6″,”form_id”:”wrapper-6920-1095″,”type”:”html”,”options”:[],”cols”:6,”conditions”:[],”wrapper_id”:”wrapper-6920-1095″,”field_label”:””,”variations”:”

      \n

    • 6 kg 500 de pièces à griller (entrecôte, tournedos, rôti…)
    • \n

    • 2 kg 500 de viande à mijoter (jarret, bourguignon, plat de côte)
    • \n

    • 3 kg de steaks hachés et/ou saucisses et/ou merguez
    • \n

    • Poids total du colis : 12 kg env.
    • \n

    “,”custom-class”:””,”formid”:”wrapper-6724-6387″},{“id”:”number-9″,”element_id”:”number-9″,”form_id”:”wrapper-6920-1095″,”type”:”number”,”options”:[],”cols”:6,”conditions”:[],”wrapper_id”:”wrapper-6920-1095″,”calculations”:”true”,”limit_min”:1,”limit_max”:150,”field_label”:”Nombre de Colis mixte”,”placeholder”:”Par exemple : 10″,”description”:””,”formid”:”wrapper-1354-2289″},{“id”:”number-10″,”element_id”:”number-10″,”form_id”:”wrapper-2861-2603″,”type”:”number”,”options”:[],”cols”:3,”conditions”:[{“element_id”:”number-9″,”rule”:”is_great”,”value”:”0″}],”wrapper_id”:”wrapper-2861-2603″,”calculations”:”true”,”limit_min”:”0″,”limit_max”:”6″,”field_label”:”kg de steack haché”,”placeholder”:”Par exemple : 3″,”formid”:”wrapper-9991-7333″,”required”:true,”required_message”:”Veuillez saisir une valeur entre 0 et 6″},{“id”:”number-11″,”element_id”:”number-11″,”form_id”:”wrapper-2861-2603″,”type”:”number”,”options”:[],”cols”:3,”conditions”:[{“element_id”:”number-9″,”rule”:”is_great”,”value”:”0″}],”wrapper_id”:”wrapper-2861-2603″,”calculations”:”true”,”limit_min”:”0″,”limit_max”:”6″,”field_label”:”kg de merguez”,”placeholder”:”Par exemple : 1″,”formid”:”wrapper-3288-3699″,”required”:true,”required_message”:”Veuillez saisir une valeur entre 0 et 6″},{“id”:”number-12″,”element_id”:”number-12″,”form_id”:”wrapper-2861-2603″,”type”:”number”,”options”:[],”cols”:3,”conditions”:[{“element_id”:”number-9″,”rule”:”is_great”,”value”:”0″}],”wrapper_id”:”wrapper-2861-2603″,”calculations”:”true”,”limit_min”:”0″,”limit_max”:”6″,”field_label”:”kg de saucisses”,”placeholder”:”Par exemple : 2″,”formid”:”wrapper-8853-6231″,”required”:true,”required_message”:”Veuillez saisir une valeur entre 0 et 6″},{“id”:”calculation-2″,”element_id”:”calculation-2″,”form_id”:”wrapper-2861-2603″,”type”:”calculation”,”options”:[],”cols”:3,”conditions”:[{“element_id”:”number-9″,”rule”:”is_great”,”value”:”0″}],”wrapper_id”:”wrapper-2861-2603″,”field_label”:”Total kg”,”placeholder”:”Par exemple : Valeur calculée”,”formula”:”{number-10}+{number-12}+{number-11}”,”suffix”:”kg”,”precision”:”0″},{“id”:”section-7″,”element_id”:”section-7″,”form_id”:”wrapper-6946-9683″,”type”:”section”,”options”:[],”cols”:12,”conditions”:[],”wrapper_id”:”wrapper-6946-9683″,”section_title”:”Vente au détail”,”cform-section-border-style”:”none”},{“id”:”number-13″,”element_id”:”number-13″,”form_id”:”wrapper-9117-5265″,”type”:”number”,”options”:[],”cols”:6,”conditions”:[],”wrapper_id”:”wrapper-9117-5265″,”calculations”:”true”,”limit_min”:1,”limit_max”:150,”field_label”:”Cheveux d’ange : 14,00 € le kg (barquette de 500gr)”,”placeholder”:”Nombre de sachet(s) de 500gr “},{“id”:”number-14″,”element_id”:”number-14″,”form_id”:”wrapper-9117-5265″,”type”:”number”,”options”:[],”cols”:6,”conditions”:[],”wrapper_id”:”wrapper-9117-5265″,”calculations”:”true”,”limit_min”:1,”limit_max”:150,”field_label”:”Foie de bœuf : 7,00 € le kg ( quantité maxi disponible :6.200 kg )”,”placeholder”:”Nombre de kilo(s)”,”formid”:”wrapper-7329-3652″},{“id”:”number-17″,”element_id”:”number-17″,”form_id”:”wrapper-4684-4558″,”type”:”number”,”options”:[],”cols”:6,”conditions”:[],”wrapper_id”:”wrapper-4684-4558″,”calculations”:”true”,”limit_min”:1,”limit_max”:150,”field_label”:”Queue de boeuf : 11,00 € le kg ( environ 1.610 kg l’unité )”,”placeholder”:”Nombre d’unité(s)”,”formid”:”wrapper-6502-8196″},{“id”:”number-16″,”element_id”:”number-16″,”form_id”:”wrapper-4684-4558″,”type”:”number”,”options”:[],”cols”:6,”conditions”:[],”wrapper_id”:”wrapper-4684-4558″,”calculations”:”true”,”limit_min”:1,”limit_max”:150,”field_label”:”Langue de boeuf 11,00 € le kg (environ 2.2 kg l’unité)”,”placeholder”:”Nombre d’unité(s)”,”formid”:”wrapper-4684-4558″},{“id”:”number-18″,”element_id”:”number-18″,”form_id”:”wrapper-5013-5445″,”type”:”number”,”options”:[],”cols”:6,”conditions”:[],”wrapper_id”:”wrapper-5013-5445″,”calculations”:”true”,”limit_min”:1,”limit_max”:150,”field_label”:”Rognons de boeuf : 7,00 € le kg ( quantité maxi disponible : 1.100 kg )”,”placeholder”:”Nombre d’unité(s)”,”formid”:”wrapper-8697-4076″},{“id”:”number-20″,”element_id”:”number-20″,”form_id”:”wrapper-5013-5445″,”type”:”number”,”options”:[],”cols”:6,”conditions”:[],”wrapper_id”:”wrapper-5013-5445″,”calculations”:”true”,”limit_min”:1,”limit_max”:150,”field_label”:”Terrine de foie de bœuf : 4,50 € (terrine de 200 gr)”,”placeholder”:”Nombre d’unité(s)”,”formid”:”wrapper-5013-5445″},{“id”:”number-19″,”element_id”:”number-19″,”form_id”:”wrapper-747-6159″,”type”:”number”,”options”:[],”cols”:6,”conditions”:[],”wrapper_id”:”wrapper-747-6159″,”calculations”:”true”,”limit_min”:1,”limit_max”:150,”field_label”:”Joue de boeuf : 11,00 € le kg ( quantité disponible environ 1.300 kg )”,”placeholder”:”Nombre de paire(s)”,”formid”:”wrapper-275-778″},{“id”:”number-15″,”element_id”:”number-15″,”form_id”:”wrapper-747-6159″,”type”:”number”,”options”:[],”cols”:6,”conditions”:[],”wrapper_id”:”wrapper-747-6159″,”calculations”:”true”,”limit_min”:1,”limit_max”:150,”field_label”:”Coeur de boeuf 7,00 € le kg ( ( environ 1.400 kg )”,”placeholder”:”Nombre de kilo(s)”,”formid”:”wrapper-747-6159″},{“id”:”section-8″,”element_id”:”section-8″,”form_id”:”wrapper-5569-7445″,”type”:”section”,”options”:[],”cols”:12,”conditions”:[],”wrapper_id”:”wrapper-5569-7445″,”section_title”:”Options”,”cform-section-border-style”:”none”},{“id”:”radio-1″,”element_id”:”radio-1″,”form_id”:”wrapper-2408-7811″,”type”:”radio”,”options”:[{“label”:”oui”,”value”:”oui”,”key”:”6377-6645″},{“label”:”non”,”value”:”non”,”key”:”9636-2203″}],”cols”:6,”conditions”:[],”wrapper_id”:”wrapper-2408-7811″,”value_type”:”radio”,”field_label”:”Souhaitez-vous être livré à domicile ? (supplément de 8 € / livraison )”,”layout”:”vertical”,”required”:true},{“id”:”radio-2″,”element_id”:”radio-2″,”form_id”:”wrapper-2408-7811″,”type”:”radio”,”options”:[{“label”:”Côtes de bœuf”,”value”:”ctes-de-buf”,”key”:”6377-6645″},{“label”:”Viande à fondue / brochettes”,”value”:”viande-fondue-brochettes”,”key”:”9636-2203″},{“label”:”Entrecôte”,”value”:”entrecte”,”limit”:””,”default”:false,”key”:”2111-8542″},{“label”:”Tournedos”,”value”:”tournedos”,”limit”:””,”default”:false,”key”:”7817-7123″}],”cols”:6,”conditions”:[],”wrapper_id”:”wrapper-2408-7811″,”value_type”:”radio”,”field_label”:”Votre préférence :”,”layout”:”vertical”,”required”:true},{“id”:”section-6″,”element_id”:”section-6″,”form_id”:”wrapper-9724-5123″,”type”:”section”,”options”:[],”cols”:12,”conditions”:[],”wrapper_id”:”wrapper-9724-5123″,”section_title”:”Vos coordonnées”,”cform-section-border-style”:”none”},{“id”:”name-1″,”element_id”:”name-1″,”form_id”:”wrapper-5829-4002″,”type”:”name”,”options”:[],”cols”:12,”conditions”:[],”wrapper_id”:”wrapper-5829-4002″,”field_label”:”Prénom Nom”,”placeholder”:”Par exemple : « Jacques Martin »”,”prefix_label”:”Préfixe”,”fname_label”:”Prénom”,”fname_placeholder”:”Par exemple : « Jean »”,”mname_label”:”Deuxième prénom”,”mname_placeholder”:”Par exemple : « Dupont »”,”lname_label”:”Nom de famille”,”lname_placeholder”:”Par exemple : « Dupont »”,”prefix”:”true”,”fname”:”true”,”mname”:”true”,”lname”:”true”,”required_message”:”Le nom est obligatoire”,”prefix_required_message”:”Le préfixe est obligatoire.”,”fname_required_message”:”Le prénom est obligatoire.”,”mname_required_message”:”Le deuxième prénom est obligatoire.”,”lname_required_message”:”Le nom est obligatoire.”,”required”:true},{“id”:”phone-1″,”element_id”:”phone-1″,”form_id”:”wrapper-1516-1249″,”type”:”phone”,”options”:[],”cols”:6,”conditions”:[],”wrapper_id”:”wrapper-1516-1249″,”required”:true,”limit”:10,”limit_type”:”characters”,”validation”:”standard”,”field_label”:”Téléphone”,”placeholder”:”Par exemple : 02 51 00 00 00″,”phone_national_country”:”FR”},{“id”:”email-1″,”element_id”:”email-1″,”form_id”:”wrapper-1516-1249″,”type”:”email”,”options”:[],”cols”:6,”conditions”:[],”wrapper_id”:”wrapper-1516-1249″,”validation”:false,”placeholder”:”Par exemple : jacques@martin.com”,”field_label”:”Adresse de messagerie”,”required”:true},{“id”:”address-1″,”element_id”:”address-1″,”form_id”:”wrapper-2738-6348″,”type”:”address”,”options”:[],”cols”:12,”conditions”:[],”wrapper_id”:”wrapper-2738-6348″,”street_address”:”true”,”address_city”:”true”,”address_state”:false,”address_zip”:”true”,”address_country”:false,”address_line”:false,”street_address_label”:”Rue”,”street_address_placeholder”:”Par exemple : 42 rue des tulipes”,”address_city_label”:”Ville”,”address_city_placeholder”:”Par exemple : Essarts en bocage”,”address_state_label”:”État/Province”,”address_state_placeholder”:”Par exemple : la Nouvelle-Galles du Sud”,”address_zip_label”:”Code postal”,”address_zip_placeholder”:”Par exemple : 85140″,”address_country_label”:”Pays”,”address_line_label”:”Appartement, suite, etc.”,”street_address_required_message”:”Ce champ est obligatoire. Veuillez saisir l’adresse postale.”,”address_zip_required_message”:”Ce champ est obligatoire. Veuillez saisir le code postal.”,”address_country_required_message”:”Ce champ est obligatoire. Veuillez sélectionner le pays.”,”address_city_required_message”:”Ce champ est obligatoire. Veuillez saisir la ville.”,”address_state_required_message”:”Ce champ est obligatoire, veuillez saisir l’État.”,”address_line_required_message”:”Ce champ est obligatoire. Veuillez saisir la ligne d’adresse.”,”street_address_required”:true,”address_city_required”:true,”address_zip_required”:true}],”settings”:{“pagination-header”:”nav”,”paginationData”:{“pagination-header-design”:”show”,”pagination-header”:”nav”},”formName”:”Formulaire commande”,”version”:”1.14.7″,”form-border-style”:”none”,”form-padding”:””,”form-border”:””,”fields-style”:”open”,”validation”:”on_submit”,”form-style”:”default”,”enable-ajax”:”true”,”autoclose”:”true”,”submission-indicator”:”show”,”indicator-label”:”Soumission en cours…”,”form-type”:”default”,”submission-behaviour”:”behaviour-thankyou”,”thankyou-message”:”<p>Merci pour votre commande, nous allons préparer votre commande.</p>”,”submitData”:{“custom-submit-text”:”Envoyer votre commande”,”custom-invalid-form-message”:”Erreur : votre formulaire n’est pas valide, veuillez corriger les erreurs !”,”conditions”:[],”condition_rule”:”any”,”condition_action”:”hide”},”validation-inline”:”1″,”form-expire”:”no_expire”,”form-padding-top”:”0″,”form-padding-right”:”0″,”form-padding-bottom”:”0″,”form-padding-left”:”0″,”form-border-width”:”0″,”form-border-radius”:”0″,”cform-label-font-family”:”Roboto”,”cform-label-custom-family”:””,”cform-label-font-size”:”12″,”cform-label-font-weight”:”bold”,”cform-title-font-family”:”Roboto”,”cform-title-custom-family”:””,”cform-title-font-size”:”45″,”cform-title-font-weight”:”normal”,”cform-title-text-align”:”left”,”cform-subtitle-font-family”:”Roboto”,”cform-subtitle-custom-font”:””,”cform-subtitle-font-size”:”18″,”cform-subtitle-font-weight”:”normal”,”cform-subtitle-text-align”:”left”,”cform-input-font-family”:”Roboto”,”cform-input-custom-font”:””,”cform-input-font-size”:”16″,”cform-input-font-weight”:”normal”,”cform-radio-font-family”:”Roboto”,”cform-radio-custom-font”:””,”cform-radio-font-size”:”14″,”cform-radio-font-weight”:”normal”,”cform-select-font-family”:”Roboto”,”cform-select-custom-family”:””,”cform-select-font-size”:”16″,”cform-select-font-weight”:”normal”,”cform-multiselect-font-family”:”Roboto”,”cform-multiselect-custom-font”:””,”cform-multiselect-font-size”:”16″,”cform-multiselect-font-weight”:”normal”,”cform-dropdown-font-family”:”Roboto”,”cform-dropdown-custom-font”:””,”cform-dropdown-font-size”:”16″,”cform-dropdown-font-weight”:”normal”,”cform-calendar-font-family”:”Roboto”,”cform-calendar-custom-font”:””,”cform-calendar-font-size”:”13″,”cform-calendar-font-weight”:”normal”,”cform-button-font-family”:”Roboto”,”cform-button-custom-font”:””,”cform-button-font-size”:”14″,”cform-button-font-weight”:”500″,”cform-timeline-font-family”:”Roboto”,”cform-timeline-custom-font”:””,”cform-timeline-font-size”:”12″,”cform-timeline-font-weight”:”normal”,”cform-pagination-font-family”:””,”cform-pagination-custom-font”:””,”cform-pagination-font-size”:”16″,”cform-pagination-font-weight”:”normal”,”payment_require_ssl”:””,”submission-file”:”delete”,”form_name”:”formulaire-commande”,”form_status”:”publish”,”cform-color-settings”:”true”,”honeypot”:”1″,”use_ajax_load”:””,”button-submit-background-static”:”#ec1653″,”use-custom-css”:””,”custom_css”:””},”client_id”:null,”notifications”:[{“slug”:”notification-1234-4567″,”label”:”Admin Email”,”email-recipients”:”default”,”recipients”:”fguillet@85.cerfrance.fr”,”email-subject”:”Nouvelle entrée de formulaire n°{submission_id} pour {form_name}”,”email-editor”:”<p>Vous avez une nouvelle soumission de formulaire : <br />{all_non_empty_fields}<br />—<br />Ce message a été envoyé depuis {site_url}.</p>”,”email-attachment”:”true”,”conditions”:[]},{“slug”:”notification-8698-9759″,”label”:”Votre commande à la Ferme de la Guiffardière”,”email-subject”:”Votre commande à la Ferme de la Guiffardière”,”email-editor”:”<p>Bonjour {name-1}</p>\n<p>Merci pour votre commande du {date_dmy}</p>\n<p>Ci dessous un récapitulatif de votre commande :</p>\n<p>{all_non_empty_fields}</p>\n<p>Nous revenons vers vous rapidement</p>\n<p>Cordialement</p>\n<p>L’équipe de la ferme</p>”,”recipients”:”fguillet@ceralis.fr”}]},”status”:”publish”,”version”:”1.14.7″}

    And my mu-plugin :
    <?php

    /**
    * Create a custom error message
    */

    add_filter(‘forminator_custom_form_submit_errors’, ‘my_custom_form_validation’, 10, 3);

    function my_custom_form_validation($submit_errors, $form_id, $field_data_array) {

    // Skip if is not the correct form
    if((int)$form_id !== 235465){
    return;
    }
    $num1 = (int) $_POST[‘number-6’];
    $num2 = (int) $_POST[‘number-7’];
    $num3 = (int) $_POST[‘number-5’];
    $num10 = (int) $_POST[‘number-10’];
    $num11 = (int) $_POST[‘number-11’];
    $num12 = (int) $_POST[‘number-12’];

    // Custom error if ID already submited
    if($num1 + $num2 + $num3<> 6){
    $submit_errors[][ ‘number-6’] = __( ‘Le total doit être égal à 6Kg, Merci de modifier vos quantités’ );
    $submit_errors[][ ‘number-7’] = __( ‘Le total doit être égal à 6Kg, Merci de modifier vos quantités’ );
    $submit_errors[][ ‘number-5’] = __( ‘Le total doit être égal à 6Kg, Merci de modifier vos quantités’ );
    }

    // Custom error if ID already submited
    if($num10 + $num11 + $num12<> 6){
    $submit_errors[][ ‘number-10’] = __( ‘Le total doit être égal à 6Kg, Merci de modifier vos quantités’ );
    $submit_errors[][ ‘number-11’] = __( ‘Le total doit être égal à 6Kg, Merci de modifier vos quantités’ );
    $submit_errors[][ ‘number-12’] = __( ‘Le total doit être égal à 6Kg, Merci de modifier vos quantités’ );
    }

    // Always return $submit_errors
    return $submit_errors;

    }

    Thread Starter ceralis

    (@ceralis)

    I must have done something wrong, because if I don’t fill in these two packages in my form it tells me that the fields configured with the mu-plugin are wrong.
    He therefore forces me to order them

    I think it may be due to my two conditions?

    Thank you for your help

    Plugin Support Adam – WPMU DEV Support

    (@wpmudev-support8)

    Hi @ceralis

    Thank you for response and sharing the form but I’m afraid I still can’t import this form for testing due to how it was posted here – it wasn’t marked as “code” in post editor which corrupted the code a bit.

    I’m sorry for the trouble but could you please share the form code again? Please use pastebin.com service instead (you don’t even have to register there) and share direct link to your “paste” here or, alternatively, export the form to the file, upload that file to your Google Drive or Dropbox or similar account and share a direct (not protected) download link here.

    We’ll then test the form to see what the issue is.

    Best regards,
    Adam

    Thread Starter ceralis

    (@ceralis)

    Sorry for the code, New try

    {"type":"form","data":{"fields":[{"id":"section-1","element_id":"section-1","form_id":"wrapper-5318-5795","type":"section","options":[],"cols":12,"conditions":[],"wrapper_id":"wrapper-5318-5795","section_title":"Colis tradition : 14\u20ac\/kg","cform-section-border-style":"none"},{"id":"html-1","element_id":"html-1","form_id":"wrapper-639-4724","type":"html","options":[],"cols":6,"conditions":[],"wrapper_id":"wrapper-639-4724","field_label":"","variations":"<ul>\n<li>6 kg 500 de pi\u00e8ces \u00e0 griller (entrec\u00f4te, tournedos, r\u00f4ti, c\u00f4te de b\u0153uf, faux-filet\u2026)<\/li>\n<li>5 kg 500 de viande \u00e0 mijoter (jarret, bourguignon, plat de c\u00f4te)<\/li>\n<li>Poids total du colis : 12 kg env.<\/li>\n<\/ul>","custom-class":""},{"id":"number-1","element_id":"number-1","form_id":"wrapper-639-4724","type":"number","options":[],"cols":6,"conditions":[],"wrapper_id":"wrapper-639-4724","calculations":"true","limit_min":1,"limit_max":150,"field_label":"Nombre de Colis tradition","placeholder":"Par exemple\u00a0: 10","description":""},{"id":"section-2","element_id":"section-2","form_id":"wrapper-6884-9330","type":"section","options":[],"cols":12,"conditions":[],"wrapper_id":"wrapper-6884-9330","section_title":"Colis d\u00e9couverte : 15,50\u20ac\/Kg","cform-section-border-style":"none","formid":"wrapper-4875-6949"},{"id":"html-3","element_id":"html-3","form_id":"wrapper-6353-9273","type":"html","options":[],"cols":6,"conditions":[],"wrapper_id":"wrapper-6353-9273","field_label":"","variations":"<ul>\n<li>3 kg de pi\u00e8ces \u00e0 griller (entrec\u00f4te : steak, r\u00f4ti, \u2026)<\/li>\n<li>1 kg de bourguignon<\/li>\n<li>1 kg de steak hach\u00e9<\/li>\n<li>1 kg de saucisse<\/li>\n<li>Poids total du colis : 6 kg env.<\/li>\n<\/ul>","custom-class":"","formid":"wrapper-1293-6365"},{"id":"number-8","element_id":"number-8","form_id":"wrapper-6353-9273","type":"number","options":[],"cols":6,"conditions":[],"wrapper_id":"wrapper-6353-9273","calculations":"true","limit_min":1,"limit_max":150,"field_label":"Nombre de Colis d\u00e9couverte","placeholder":"Par exemple\u00a0: 10","description":"","formid":"wrapper-8482-9288"},{"id":"section-3","element_id":"section-3","form_id":"wrapper-9988-9994","type":"section","options":[],"cols":12,"conditions":[],"wrapper_id":"wrapper-9988-9994","section_title":"Colis Veau de lait : 15.50\u20ac\/ Kg","cform-section-border-style":"none","formid":"wrapper-2157-6460"},{"id":"html-4","element_id":"html-4","form_id":"wrapper-4537-7302","type":"html","options":[],"cols":6,"conditions":[],"wrapper_id":"wrapper-4537-7302","field_label":"","variations":"<ul>\n<li>1.5 kg de r\u00f4ti<\/li>\n<li>1.3 kg d\u2019escalope<\/li>\n<li>1.3 kg de c\u00f4te<\/li>\n<li>2.7 kg de saut\u00e9 de veau, osso bucco, tendron.<\/li>\n<li>0.2 kg de paupiette<\/li>\n<li>Poids total du colis : 7 kg env.<\/li>\n<\/ul>","custom-class":"","formid":"wrapper-8129-3333"},{"id":"number-3","element_id":"number-3","form_id":"wrapper-4537-7302","type":"number","options":[],"cols":6,"conditions":[],"wrapper_id":"wrapper-4537-7302","calculations":"true","limit_min":1,"limit_max":150,"field_label":"Nombre de Colis veau de lait","placeholder":"Par exemple\u00a0: 10","description":"","formid":"wrapper-9851-2270"},{"id":"section-4","element_id":"section-4","form_id":"wrapper-5720-9029","type":"section","options":[],"cols":12,"conditions":[],"wrapper_id":"wrapper-5720-9029","section_title":"Colis grillade\u00a0: 15\u20ac\/Kg","cform-section-border-style":"none","formid":"wrapper-3638-9068"},{"id":"html-5","element_id":"html-5","form_id":"wrapper-9499-7633","type":"html","options":[],"cols":6,"conditions":[],"wrapper_id":"wrapper-9499-7633","field_label":"","variations":"<ul>\n<li>6 kg de pi\u00e8ces \u00e0 griller (entrec\u00f4te, tournedos, r\u00f4ti\u2026)<\/li>\n<li>6 kg\u00a0 de saucisses de b\u0153uf et\/ou steaks hach\u00e9s et\/ou merguez<\/li>\n<li>Poids total du colis : 12 Kg env.<\/li>\n<\/ul>","custom-class":"","formid":"wrapper-2554-4561"},{"id":"number-4","element_id":"number-4","form_id":"wrapper-9499-7633","type":"number","options":[],"cols":6,"conditions":[],"wrapper_id":"wrapper-9499-7633","calculations":"true","limit_min":1,"limit_max":150,"field_label":"Nombre de Colis grillades (12kg environ) : 15\u20ac\/kg","placeholder":"Par exemple\u00a0: 10","description":"","formid":"wrapper-5888-1310"},{"id":"number-6","element_id":"number-6","form_id":"wrapper-3864-2167","type":"number","options":[],"cols":3,"conditions":[{"element_id":"number-4","rule":"is_great","value":"0"}],"wrapper_id":"wrapper-3864-2167","calculations":"true","limit_min":"0","limit_max":"6","field_label":"kg de steack hach\u00e9","placeholder":"Par exemple\u00a0: 3","formid":"wrapper-9599-2554","required":true,"default_value":"","required_message":"Veuillez saisir une valeur entre 0 et 6"},{"id":"number-7","element_id":"number-7","form_id":"wrapper-3864-2167","type":"number","options":[],"cols":3,"conditions":[{"element_id":"number-4","rule":"is_great","value":"0"}],"wrapper_id":"wrapper-3864-2167","calculations":"true","limit_min":"0","limit_max":"6","field_label":"kg de merguez","placeholder":"Par exemple\u00a0: 1","formid":"wrapper-847-9030","required":true,"default_value":"","required_message":"Veuillez saisir une valeur entre 0 et 6"},{"id":"number-5","element_id":"number-5","form_id":"wrapper-3864-2167","type":"number","options":[],"cols":3,"conditions":[{"element_id":"number-4","rule":"is_great","value":"0"}],"wrapper_id":"wrapper-3864-2167","calculations":"true","limit_min":"0","limit_max":"6","field_label":"kg de saucisses","placeholder":"Par exemple\u00a0: 2","required":true,"default_value":"","required_message":"Veuillez saisir une valeur entre 0 et 6"},{"id":"calculation-1","element_id":"calculation-1","form_id":"wrapper-3864-2167","type":"calculation","options":[],"cols":3,"conditions":[{"element_id":"number-4","rule":"is_great","value":"0"}],"wrapper_id":"wrapper-3864-2167","field_label":"Total kg","placeholder":"Par exemple\u00a0: Valeur calcul\u00e9e","hidden":false,"formula":"{number-6}+{number-7}+{number-5}","precision":"0","suffix":"kg"},{"id":"section-5","element_id":"section-5","form_id":"wrapper-3635-623","type":"section","options":[],"cols":12,"conditions":[],"wrapper_id":"wrapper-3635-623","section_title":"Colis mixte : 14,50\u20ac\/Kg","cform-section-border-style":"none","formid":"wrapper-1443-9791"},{"id":"html-6","element_id":"html-6","form_id":"wrapper-6920-1095","type":"html","options":[],"cols":6,"conditions":[],"wrapper_id":"wrapper-6920-1095","field_label":"","variations":"<ul>\n<li>6 kg 500 de pi\u00e8ces \u00e0 griller (entrec\u00f4te, tournedos, r\u00f4ti\u2026)<\/li>\n<li>2 kg 500 de viande \u00e0 mijoter (jarret, bourguignon, plat de c\u00f4te)<\/li>\n<li>3 kg de steaks hach\u00e9s et\/ou saucisses et\/ou merguez<\/li>\n<li>Poids total du colis : 12 kg env.<\/li>\n<\/ul>","custom-class":"","formid":"wrapper-6724-6387"},{"id":"number-9","element_id":"number-9","form_id":"wrapper-6920-1095","type":"number","options":[],"cols":6,"conditions":[],"wrapper_id":"wrapper-6920-1095","calculations":"true","limit_min":1,"limit_max":150,"field_label":"Nombre de Colis mixte","placeholder":"Par exemple\u00a0: 10","description":"","formid":"wrapper-1354-2289"},{"id":"number-10","element_id":"number-10","form_id":"wrapper-2861-2603","type":"number","options":[],"cols":3,"conditions":[{"element_id":"number-9","rule":"is_great","value":"0"}],"wrapper_id":"wrapper-2861-2603","calculations":"true","limit_min":"0","limit_max":"6","field_label":"kg de steack hach\u00e9","placeholder":"Par exemple\u00a0: 3","formid":"wrapper-9991-7333","required":true,"required_message":"Veuillez saisir une valeur entre 0 et 6"},{"id":"number-11","element_id":"number-11","form_id":"wrapper-2861-2603","type":"number","options":[],"cols":3,"conditions":[{"element_id":"number-9","rule":"is_great","value":"0"}],"wrapper_id":"wrapper-2861-2603","calculations":"true","limit_min":"0","limit_max":"6","field_label":"kg de merguez","placeholder":"Par exemple\u00a0: 1","formid":"wrapper-3288-3699","required":true,"required_message":"Veuillez saisir une valeur entre 0 et 6"},{"id":"number-12","element_id":"number-12","form_id":"wrapper-2861-2603","type":"number","options":[],"cols":3,"conditions":[{"element_id":"number-9","rule":"is_great","value":"0"}],"wrapper_id":"wrapper-2861-2603","calculations":"true","limit_min":"0","limit_max":"6","field_label":"kg de saucisses","placeholder":"Par exemple\u00a0: 2","formid":"wrapper-8853-6231","required":true,"required_message":"Veuillez saisir une valeur entre 0 et 6"},{"id":"calculation-2","element_id":"calculation-2","form_id":"wrapper-2861-2603","type":"calculation","options":[],"cols":3,"conditions":[{"element_id":"number-9","rule":"is_great","value":"0"}],"wrapper_id":"wrapper-2861-2603","field_label":"Total kg","placeholder":"Par exemple\u00a0: Valeur calcul\u00e9e","formula":"{number-10}+{number-12}+{number-11}","suffix":"kg","precision":"0"},{"id":"section-7","element_id":"section-7","form_id":"wrapper-6946-9683","type":"section","options":[],"cols":12,"conditions":[],"wrapper_id":"wrapper-6946-9683","section_title":"Vente au d\u00e9tail","cform-section-border-style":"none"},{"id":"number-13","element_id":"number-13","form_id":"wrapper-9117-5265","type":"number","options":[],"cols":6,"conditions":[],"wrapper_id":"wrapper-9117-5265","calculations":"true","limit_min":1,"limit_max":150,"field_label":"Cheveux d'ange : 14,00 \u20ac le kg (barquette de 500gr)","placeholder":"Nombre de sachet(s) de 500gr "},{"id":"number-14","element_id":"number-14","form_id":"wrapper-9117-5265","type":"number","options":[],"cols":6,"conditions":[],"wrapper_id":"wrapper-9117-5265","calculations":"true","limit_min":1,"limit_max":150,"field_label":"Foie de b\u0153uf : 7,00 \u20ac le kg ( quantit\u00e9 maxi disponible :6.200 kg )","placeholder":"Nombre de kilo(s)","formid":"wrapper-7329-3652"},{"id":"number-17","element_id":"number-17","form_id":"wrapper-4684-4558","type":"number","options":[],"cols":6,"conditions":[],"wrapper_id":"wrapper-4684-4558","calculations":"true","limit_min":1,"limit_max":150,"field_label":"Queue de boeuf : 11,00 \u20ac le kg ( environ 1.610 kg l'unit\u00e9 )","placeholder":"Nombre d'unit\u00e9(s)","formid":"wrapper-6502-8196"},{"id":"number-16","element_id":"number-16","form_id":"wrapper-4684-4558","type":"number","options":[],"cols":6,"conditions":[],"wrapper_id":"wrapper-4684-4558","calculations":"true","limit_min":1,"limit_max":150,"field_label":"Langue de boeuf 11,00 \u20ac le kg (environ 2.2 kg l'unit\u00e9)","placeholder":"Nombre d'unit\u00e9(s)","formid":"wrapper-4684-4558"},{"id":"number-18","element_id":"number-18","form_id":"wrapper-5013-5445","type":"number","options":[],"cols":6,"conditions":[],"wrapper_id":"wrapper-5013-5445","calculations":"true","limit_min":1,"limit_max":150,"field_label":"Rognons de boeuf : 7,00 \u20ac le kg ( quantit\u00e9 maxi disponible : 1.100 kg )","placeholder":"Nombre d'unit\u00e9(s)","formid":"wrapper-8697-4076"},{"id":"number-20","element_id":"number-20","form_id":"wrapper-5013-5445","type":"number","options":[],"cols":6,"conditions":[],"wrapper_id":"wrapper-5013-5445","calculations":"true","limit_min":1,"limit_max":150,"field_label":"Terrine de foie de b\u0153uf : 4,50 \u20ac (terrine de 200 gr)","placeholder":"Nombre d'unit\u00e9(s)","formid":"wrapper-5013-5445"},{"id":"number-19","element_id":"number-19","form_id":"wrapper-747-6159","type":"number","options":[],"cols":6,"conditions":[],"wrapper_id":"wrapper-747-6159","calculations":"true","limit_min":1,"limit_max":150,"field_label":"Joue de boeuf : 11,00 \u20ac le kg ( quantit\u00e9 disponible environ 1.300 kg )","placeholder":"Nombre de paire(s)","formid":"wrapper-275-778"},{"id":"number-15","element_id":"number-15","form_id":"wrapper-747-6159","type":"number","options":[],"cols":6,"conditions":[],"wrapper_id":"wrapper-747-6159","calculations":"true","limit_min":1,"limit_max":150,"field_label":"Coeur de boeuf 7,00 \u20ac le kg ( ( environ 1.400 kg )","placeholder":"Nombre de kilo(s)","formid":"wrapper-747-6159"},{"id":"section-8","element_id":"section-8","form_id":"wrapper-5569-7445","type":"section","options":[],"cols":12,"conditions":[],"wrapper_id":"wrapper-5569-7445","section_title":"Options","cform-section-border-style":"none"},{"id":"radio-1","element_id":"radio-1","form_id":"wrapper-2408-7811","type":"radio","options":[{"label":"oui","value":"oui","key":"6377-6645"},{"label":"non","value":"non","key":"9636-2203"}],"cols":6,"conditions":[],"wrapper_id":"wrapper-2408-7811","value_type":"radio","field_label":"Souhaitez-vous \u00eatre livr\u00e9 \u00e0 domicile ? (suppl\u00e9ment de 8 \u20ac \/ livraison )","layout":"vertical","required":true},{"id":"radio-2","element_id":"radio-2","form_id":"wrapper-2408-7811","type":"radio","options":[{"label":"C\u00f4tes de b\u0153uf","value":"ctes-de-buf","key":"6377-6645"},{"label":"Viande \u00e0 fondue \/ brochettes","value":"viande-fondue-brochettes","key":"9636-2203"},{"label":"Entrec\u00f4te","value":"entrecte","limit":"","default":false,"key":"2111-8542"},{"label":"Tournedos","value":"tournedos","limit":"","default":false,"key":"7817-7123"}],"cols":6,"conditions":[],"wrapper_id":"wrapper-2408-7811","value_type":"radio","field_label":"Votre pr\u00e9f\u00e9rence :","layout":"vertical","required":true},{"id":"section-6","element_id":"section-6","form_id":"wrapper-9724-5123","type":"section","options":[],"cols":12,"conditions":[],"wrapper_id":"wrapper-9724-5123","section_title":"Vos coordonn\u00e9es","cform-section-border-style":"none"},{"id":"name-1","element_id":"name-1","form_id":"wrapper-5829-4002","type":"name","options":[],"cols":12,"conditions":[],"wrapper_id":"wrapper-5829-4002","field_label":"Pr\u00e9nom Nom","placeholder":"Par exemple\u00a0: \u00ab\u00a0Jacques Martin\u00a0\u00bb","prefix_label":"Pr\u00e9fixe","fname_label":"Pr\u00e9nom","fname_placeholder":"Par exemple\u00a0: \u00ab\u00a0Jean\u00a0\u00bb","mname_label":"Deuxi\u00e8me pr\u00e9nom","mname_placeholder":"Par exemple\u00a0: \u00ab\u00a0Dupont\u00a0\u00bb","lname_label":"Nom de famille","lname_placeholder":"Par exemple\u00a0: \u00ab\u00a0Dupont\u00a0\u00bb","prefix":"true","fname":"true","mname":"true","lname":"true","required_message":"Le nom est obligatoire","prefix_required_message":"Le pr\u00e9fixe est obligatoire.","fname_required_message":"Le pr\u00e9nom est obligatoire.","mname_required_message":"Le deuxi\u00e8me pr\u00e9nom est obligatoire.","lname_required_message":"Le nom est obligatoire.","required":true},{"id":"phone-1","element_id":"phone-1","form_id":"wrapper-1516-1249","type":"phone","options":[],"cols":6,"conditions":[],"wrapper_id":"wrapper-1516-1249","required":true,"limit":10,"limit_type":"characters","validation":"standard","field_label":"T\u00e9l\u00e9phone","placeholder":"Par exemple\u00a0: 02 51 00 00 00","phone_national_country":"FR"},{"id":"email-1","element_id":"email-1","form_id":"wrapper-1516-1249","type":"email","options":[],"cols":6,"conditions":[],"wrapper_id":"wrapper-1516-1249","validation":false,"placeholder":"Par exemple\u00a0: jacques@martin.com","field_label":"Adresse de messagerie","required":true},{"id":"address-1","element_id":"address-1","form_id":"wrapper-2738-6348","type":"address","options":[],"cols":12,"conditions":[],"wrapper_id":"wrapper-2738-6348","street_address":"true","address_city":"true","address_state":false,"address_zip":"true","address_country":false,"address_line":false,"street_address_label":"Rue","street_address_placeholder":"Par exemple\u00a0: 42 rue des tulipes","address_city_label":"Ville","address_city_placeholder":"Par exemple\u00a0: Essarts en bocage","address_state_label":"\u00c9tat\/Province","address_state_placeholder":"Par exemple\u00a0: la Nouvelle-Galles du Sud","address_zip_label":"Code postal","address_zip_placeholder":"Par exemple\u00a0: 85140","address_country_label":"Pays","address_line_label":"Appartement, suite, etc.","street_address_required_message":"Ce champ est obligatoire. Veuillez saisir l\u2019adresse postale.","address_zip_required_message":"Ce champ est obligatoire. Veuillez saisir le code postal.","address_country_required_message":"Ce champ est obligatoire. Veuillez s\u00e9lectionner le pays.","address_city_required_message":"Ce champ est obligatoire. Veuillez saisir la ville.","address_state_required_message":"Ce champ est obligatoire, veuillez saisir l\u2019\u00c9tat.","address_line_required_message":"Ce champ est obligatoire. Veuillez saisir la ligne d\u2019adresse.","street_address_required":true,"address_city_required":true,"address_zip_required":true}],"settings":{"pagination-header":"nav","paginationData":{"pagination-header-design":"show","pagination-header":"nav"},"formName":"Formulaire commande","version":"1.14.7","form-border-style":"none","form-padding":"","form-border":"","fields-style":"open","validation":"on_submit","form-style":"default","enable-ajax":"true","autoclose":"true","submission-indicator":"show","indicator-label":"Soumission en cours\u2026","form-type":"default","submission-behaviour":"behaviour-thankyou","thankyou-message":"<p>Merci pour votre commande, nous allons pr\u00e9parer votre commande.<\/p>","submitData":{"custom-submit-text":"Envoyer votre commande","custom-invalid-form-message":"Erreur\u00a0: votre formulaire n\u2019est pas valide, veuillez corriger les erreurs\u00a0!","conditions":[],"condition_rule":"any","condition_action":"hide"},"validation-inline":"1","form-expire":"no_expire","form-padding-top":"0","form-padding-right":"0","form-padding-bottom":"0","form-padding-left":"0","form-border-width":"0","form-border-radius":"0","cform-label-font-family":"Roboto","cform-label-custom-family":"","cform-label-font-size":"12","cform-label-font-weight":"bold","cform-title-font-family":"Roboto","cform-title-custom-family":"","cform-title-font-size":"45","cform-title-font-weight":"normal","cform-title-text-align":"left","cform-subtitle-font-family":"Roboto","cform-subtitle-custom-font":"","cform-subtitle-font-size":"18","cform-subtitle-font-weight":"normal","cform-subtitle-text-align":"left","cform-input-font-family":"Roboto","cform-input-custom-font":"","cform-input-font-size":"16","cform-input-font-weight":"normal","cform-radio-font-family":"Roboto","cform-radio-custom-font":"","cform-radio-font-size":"14","cform-radio-font-weight":"normal","cform-select-font-family":"Roboto","cform-select-custom-family":"","cform-select-font-size":"16","cform-select-font-weight":"normal","cform-multiselect-font-family":"Roboto","cform-multiselect-custom-font":"","cform-multiselect-font-size":"16","cform-multiselect-font-weight":"normal","cform-dropdown-font-family":"Roboto","cform-dropdown-custom-font":"","cform-dropdown-font-size":"16","cform-dropdown-font-weight":"normal","cform-calendar-font-family":"Roboto","cform-calendar-custom-font":"","cform-calendar-font-size":"13","cform-calendar-font-weight":"normal","cform-button-font-family":"Roboto","cform-button-custom-font":"","cform-button-font-size":"14","cform-button-font-weight":"500","cform-timeline-font-family":"Roboto","cform-timeline-custom-font":"","cform-timeline-font-size":"12","cform-timeline-font-weight":"normal","cform-pagination-font-family":"","cform-pagination-custom-font":"","cform-pagination-font-size":"16","cform-pagination-font-weight":"normal","payment_require_ssl":"","submission-file":"delete","form_name":"formulaire-commande","form_status":"publish","cform-color-settings":"true","honeypot":"1","use_ajax_load":"","button-submit-background-static":"#ec1653","use-custom-css":"","custom_css":""},"client_id":null,"notifications":[{"slug":"notification-1234-4567","label":"Admin Email","email-recipients":"default","recipients":"fguillet@85.cerfrance.fr","email-subject":"Nouvelle entr\u00e9e de formulaire n\u00b0{submission_id} pour {form_name}","email-editor":"<p>Vous avez une nouvelle soumission de formulaire\u00a0: <br \/>{all_non_empty_fields}<br \/>---<br \/>Ce message a \u00e9t\u00e9 envoy\u00e9 depuis {site_url}.<\/p>","email-attachment":"true","conditions":[]},{"slug":"notification-8698-9759","label":"Votre commande \u00e0 la Ferme de la Guiffardi\u00e8re","email-subject":"Votre commande \u00e0 la Ferme de la Guiffardi\u00e8re","email-editor":"<p>Bonjour {name-1}<\/p>\n<p>Merci pour votre commande du {date_dmy}<\/p>\n<p>Ci dessous un r\u00e9capitulatif de votre commande :<\/p>\n<p>{all_non_empty_fields}<\/p>\n<p>Nous revenons vers vous rapidement<\/p>\n<p>Cordialement<\/p>\n<p>L'\u00e9quipe de la ferme<\/p>","recipients":"fguillet@ceralis.fr"}]},"status":"publish","version":"1.14.7"}

    And th php file :

    <?php
    
    /**
    * Create a custom error message
    */
    
    add_filter('forminator_custom_form_submit_errors', 'my_custom_form_validation', 10, 3);
    
    function my_custom_form_validation($submit_errors, $form_id, $field_data_array) {
    
       // Skip if is not the correct form
      if((int)$form_id !== 235465){
        return;
      }
      $num1 = (int) $_POST['number-6'];
      $num2 = (int) $_POST['number-7'];
      $num3 = (int) $_POST['number-5'];
      $num10 = (int) $_POST['number-10'];
      $num11 = (int) $_POST['number-11'];
      $num12 = (int) $_POST['number-12'];
    
      // Custom error if ID already submited
      if($num1 + $num2 + $num3<> 6){
          $submit_errors[][ 'number-6'] = __( 'Le total doit être égal à 6Kg, Merci de modifier vos quantités' );
          $submit_errors[][ 'number-7'] = __( 'Le total doit être égal à 6Kg, Merci de modifier vos quantités' );
    	  $submit_errors[][ 'number-5'] = __( 'Le total doit être égal à 6Kg, Merci de modifier vos quantités' );
      }
      
      // Custom error if ID already submited
      if($num10 + $num11 + $num12<> 6){
          $submit_errors[][ 'number-10'] = __( 'Le total doit être égal à 6Kg, Merci de modifier vos quantités' );
          $submit_errors[][ 'number-11'] = __( 'Le total doit être égal à 6Kg, Merci de modifier vos quantités' );
    	  $submit_errors[][ 'number-12'] = __( 'Le total doit être égal à 6Kg, Merci de modifier vos quantités' );
      }
    
      // Always return $submit_errors
      return $submit_errors;
    
    }
    Thread Starter ceralis

    (@ceralis)

    Thread Starter ceralis

    (@ceralis)

    Hello

    The fact that it blocks me to grab my kg even if I do not choose the collis is due to the faity that I put “<>” instead of “> 6”.

    But my sum must be 6, no more no less

    Thank you for your help

    Thread Starter ceralis

    (@ceralis)

    And with “> 6” instead of “<>” the form is replaced by the fields in error

    So your code works fine, but how do you get a condition that the sum must be 6?

    Thread Starter ceralis

    (@ceralis)

    I found the solution !

    If no value is entered, forminator considers the field to be zero

    When I put different it was therefore 0 + 0 + 0 and so it was different from 6

    So I added an additional condition (see the code) on the fact that the choice of the package is greater than zero

    Thank you again and happy to use this plugin for my different websites

    <?php
    
    /**
    * Create a custom error message
    */
    
    add_filter('forminator_custom_form_submit_errors', 'my_custom_form_validation', 10, 3);
    
    function my_custom_form_validation($submit_errors, $form_id, $field_data_array) {
    
       // Skip if is not the correct form
      if((int)$form_id !== 235465){
        return;
      }
      $num1 = (int) $_POST['number-6'];
      $num2 = (int) $_POST['number-7'];
      $num3 = (int) $_POST['number-5'];
      $num4 = (int) $_POST['number-4'];
      $num9 = (int) $_POST['number-9'];
      $num10 = (int) $_POST['number-10'];
      $num11 = (int) $_POST['number-11'];
      $num12 = (int) $_POST['number-12'];
    
      // Custom error if ID already submited
      if($num1 + $num2 + $num3!= 6 && $num4>0){
          $submit_errors[][ 'number-6'] = __( 'Le total doit être égal à 6Kg, Merci de modifier vos quantités' );
          $submit_errors[][ 'number-7'] = __( 'Le total doit être égal à 6Kg, Merci de modifier vos quantités' );
    	  $submit_errors[][ 'number-5'] = __( 'Le total doit être égal à 6Kg, Merci de modifier vos quantités' );
      }
      
      // Custom error if ID already submited
      if($num10 + $num11 + $num12!= 6 && $num9>0){
          $submit_errors[][ 'number-10'] = __( 'Le total doit être égal à 6Kg, Merci de modifier vos quantités' );
          $submit_errors[][ 'number-11'] = __( 'Le total doit être égal à 6Kg, Merci de modifier vos quantités' );
    	  $submit_errors[][ 'number-12'] = __( 'Le total doit être égal à 6Kg, Merci de modifier vos quantités' );
      }
    
      // Always return $submit_errors
      return $submit_errors;
    
    }
    Plugin Support Predrag – WPMU DEV Support

    (@wpmudev-support1)

    Hi @ceralis,

    Glad to hear you found the solution and thanks for taking the time to share your solution, I’m sure others will find it helpful as well!

    I will mark the ticket as resolved but if you have any followup questions you can of course reopen it.

    Cheers,
    Predrag

Viewing 13 replies - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.