Skip to content
Snippets Groups Projects
Commit 566a9f19 authored by dyszczo's avatar dyszczo
Browse files

fix: When no value is provided use default in validation

parent ba558262
No related branches found
No related tags found
No related merge requests found
Pipeline #5618 passed with warnings with stages
in 1 minute and 50 seconds
# Changelog # Changelog
## [2.4.2] - 2021-03-10
### Fixed
- When no value is provided use default in validation
## [2.4.1] - 2021-02-01 ## [2.4.1] - 2021-02-01
### Fixed ### Fixed
- Invalid namespaces - Invalid namespaces
......
...@@ -117,7 +117,7 @@ class FormWithFields implements Form, ContainerForm, FieldProvider { ...@@ -117,7 +117,7 @@ class FormWithFields implements Form, ContainerForm, FieldProvider {
*/ */
public function is_valid() { public function is_valid() {
foreach ( $this->fields as $field ) { foreach ( $this->fields as $field ) {
$field_value = isset( $this->updated_data[ $field->get_name() ] ) ? $this->updated_data[ $field->get_name() ] : null; $field_value = isset( $this->updated_data[ $field->get_name() ] ) ? $this->updated_data[ $field->get_name() ] : $field->get_default_value();
$field_validator = $field->get_validator(); $field_validator = $field->get_validator();
if ( ! $field_validator->is_valid( $field_value ) ) { if ( ! $field_validator->is_valid( $field_value ) ) {
return false; return false;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment