From 746871fe93483986980083ee8c457fa349d6996e Mon Sep 17 00:00:00 2001 From: Niek Brekelmans Date: Tue, 28 Apr 2020 23:05:13 +0200 Subject: [PATCH] Bug if all fields are empty If no fields have been filled in (and no fields are required), `$this->form_data = null`, which throws an exception. This fixes that bug --- src/FormComponent.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FormComponent.php b/src/FormComponent.php index 29129fb..2002822 100644 --- a/src/FormComponent.php +++ b/src/FormComponent.php @@ -70,7 +70,7 @@ public function submit() $field_names = []; foreach ($this->fields() as $field) $field_names[] = $field->name; - $this->form_data = Arr::only($this->form_data, $field_names); + $this->form_data = Arr::only($this->form_data ?? [], $field_names); $this->success(); }