From db460ed57f1e53973d94c3841ca1850a78f94db0 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Fri, 15 Oct 2010 02:54:02 +0000 Subject: [PATCH] MINOR Better error handling in Form::__construct() (fixes #5649) (from r105912) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112511 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- forms/Form.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/forms/Form.php b/forms/Form.php index 74559863a..a599989bf 100755 --- a/forms/Form.php +++ b/forms/Form.php @@ -143,6 +143,10 @@ class Form extends RequestHandler { */ function __construct($controller, $name, FieldSet $fields, FieldSet $actions, $validator = null) { parent::__construct(); + + if(!$fields instanceof FieldSet) throw new InvalidArgumentException('$fields must be a valid FieldSet instance'); + if(!$actions instanceof FieldSet) throw new InvalidArgumentException('$fields must be a valid FieldSet instance'); + if($validator && !$validator instanceof Validator) throw new InvalidArgumentException('$validator must be a Valdidator instance'); $fields->setForm($this); $actions->setForm($this);