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
This commit is contained in:
Ingo Schommer 2010-10-15 02:54:02 +00:00
parent 09d4d0ccb3
commit db460ed57f

View File

@ -144,6 +144,10 @@ class Form extends RequestHandler {
function __construct($controller, $name, FieldSet $fields, FieldSet $actions, $validator = null) { function __construct($controller, $name, FieldSet $fields, FieldSet $actions, $validator = null) {
parent::__construct(); 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); $fields->setForm($this);
$actions->setForm($this); $actions->setForm($this);