From 022826883f5ea68a55d197c1eda959af9f3ecc1c Mon Sep 17 00:00:00 2001 From: Simon Asika Date: Sun, 21 Jan 2024 17:13:59 +0800 Subject: [PATCH] Must get field --- src/Form.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Form.php b/src/Form.php index 0a0ca0d..4b04ed1 100644 --- a/src/Form.php +++ b/src/Form.php @@ -310,6 +310,12 @@ public function getField(string $namespace): ?AbstractField return $this->fields[$namespace] ?? null; } + public function mustGetField(string $namespace): AbstractField + { + return $this->getField($namespace) + ?? throw new \OutOfBoundsException("Field \"$namespace\" not exists."); + } + public function hasField(string $namespace): bool { return isset($this->fields[$namespace]);