PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.9
GiveWP – Donation Plugin and Fundraising Platform v4.16.9
4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 All 255 releases
← All changes | src/Framework/FieldsAPI/Actions/CreateValidatorFromForm.php +4 -1 2.30.04.16.9 View file →
@@ -9,8 +9,9 @@
9 9
10 10 class CreateValidatorFromForm
11 11 {
12 12 /**
13 + * @since 3.0.0 Update validation rules with optional as default.
13 14 * @since 2.24.0
14 15 */
15 16 public function __invoke(Form $form, array $values): Validator
16 17 {
@@ -17,9 +18,11 @@
17 18 $labels = [];
18 19 $rules = [];
19 20
20 21 foreach ($form->getFields() as $field) {
21 - $rules[$field->getName()] = $field->getValidationRules();
22 + $rules[$field->getName()] = (new UpdateValidationRulesWithOptionalAsDefault())(
23 + $field->getValidationRules()
24 + );
22 25
23 26 if (method_exists($field, 'getLabel')) {
24 27 $labels[$field->getName()] = $field->getLabel();
25 28 }