Validates submission fields for this element.
Description
See also
Parameters
- $values
-
(array) (Required) Array of
$field => $value
pairs with the main field having a key of '_main'. - $submission
-
(awsmug\Torro_Forms\DB_Objects\Submissions\Submission) (Required) Submission the values belong to.
Return
(array) Validated array where each value is either the validated value, or an error object on failure.
Source
File: src/db-objects/elements/element.php
public function validate_fields( $values, $submission ) { $element_type = $this->get_element_type(); if ( ! $element_type ) { return array(); } if ( is_a( $element_type, Non_Input_Element_Type_Interface::class ) ) { return array(); } $main_value = null; if ( isset( $values['_main'] ) ) { $main_value = $values['_main']; unset( $values['_main'] ); } $validated = array(); if ( is_a( $element_type, Multi_Field_Element_Type_Interface::class ) ) { $validated = $element_type->validate_additional_fields( $values, $this, $submission ); } $validated['_main'] = $element_type->validate_field( $main_value, $this, $submission ); return $validated; }
Changelog
Version | Description |
---|---|
1.0.0 | Introduced. |