From 88cafd1b75eee37cdc5b324ad13b8d844ff801bb Mon Sep 17 00:00:00 2001 From: Bart Jaskulski <bjaskulski@protonmail.com> Date: Fri, 8 Apr 2022 14:39:26 +0200 Subject: [PATCH] fix: return empty data if no fields added to form --- src/Form/FormWithFields.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Form/FormWithFields.php b/src/Form/FormWithFields.php index c3c965d..8d4961d 100644 --- a/src/Form/FormWithFields.php +++ b/src/Form/FormWithFields.php @@ -180,6 +180,10 @@ class FormWithFields implements Form, ContainerForm, FieldProvider { } public function get_data(): array { + if ( empty( $this->get_fields() ) ) { + return []; + } + $data = $this->updated_data; foreach ( $this->get_fields() as $field ) { -- GitLab