Changeset 1519338
- Timestamp:
- 10/21/2016 03:38:13 PM (9 years ago)
- Location:
- bluecube-mighty-gravity-forms
- Files:
-
- 7 added
- 2 edited
-
tags/1.1.4 (added)
-
tags/1.1.4/bluecube-mighty-gravityforms.php (added)
-
tags/1.1.4/class (added)
-
tags/1.1.4/class/Mighty_Gravity_Forms.php (added)
-
tags/1.1.4/readme.txt (added)
-
tags/1.1.4/template (added)
-
tags/1.1.4/template/number-range-change-front-end-code.php (added)
-
trunk/class/Mighty_Gravity_Forms.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
bluecube-mighty-gravity-forms/trunk/class/Mighty_Gravity_Forms.php
r1516705 r1519338 643 643 644 644 /** 645 * Our custom validation must take place before some of the 646 * built-in validation e.g. `required` value validation. 647 * @param $field 648 * @return bool 649 */ 650 protected function shouldNotBeValidatedWithCustomFunctions($field) { 651 652 $field_value = rgpost('input_' . $field->id); 653 $should_not_be_validated = false; 654 655 // Is it required with no value? 656 // If so, we would not want to apply the custom validation 657 // because the built-in `require` validation should be returned 658 // by Gravity Forms 659 if ($field->isRequired) { 660 661 if (is_array($field_value)) { 662 663 if (empty($field_value)) { 664 $should_not_be_validated = true; 665 } elseif($field->type == 'date') { 666 // For date fields, all the items must have non-empty values 667 if ( in_array('', $field_value) ) { 668 $should_not_be_validated = true; 669 } 670 } 671 672 } elseif ($field_value == '') { 673 $should_not_be_validated = true; 674 } 675 } 676 677 return $should_not_be_validated; 678 } 679 680 /** 645 681 * Enforces the custom validation rule 646 682 * @param $validation_rule … … 649 685 protected function customValidationCheck($validation_rule, $field) { 650 686 651 // Ignore the non-required field with no value 652 $field_value = rgpost('input_' . $field->id); 653 if ( 654 ($field_value == '' && ! $field->isRequired) 655 || $field->validation_message != '' 656 ) { 657 // There's no need for custom validation 687 if ($this->shouldNotBeValidatedWithCustomFunctions($field)) 658 688 return; 659 }660 689 661 690 $function_name = $validation_rule[1]; -
bluecube-mighty-gravity-forms/trunk/readme.txt
r1516705 r1519338 5 5 Requires at least: 4.6 6 6 Tested up to: 4.6.1 7 Stable tag: 1.1. 37 Stable tag: 1.1.4 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 35 35 == Changelog == 36 36 37 = 1.1.4 = 38 * Fixing a bug which was caused by applying a custom validation to a required date field with the type of dropdown. 39 37 40 = 1.1.3 = 38 41 * Fixing a bug which sent unintentional headers.
Note: See TracChangeset
for help on using the changeset viewer.