Skip to content

Commit

Permalink
FIX Switch instanceof logic to check for a non-FormField
Browse files Browse the repository at this point in the history
  • Loading branch information
robbieaverill committed Dec 12, 2018
1 parent 5bd7420 commit 19d6497
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Model/ResourceFilter.php
Expand Up @@ -77,11 +77,16 @@ public function getCMSFields()
return parent::getCMSFields();
}

/**
* {@inheritdoc}
*
* @throws InvalidArgumentException If the provided Type is not an instance of FormField
*/
public function forTemplate()
{
$options = json_decode($this->TypeOptions, true);
$field = Injector::inst()->createWithArgs($this->Type, $options);
if ($field instanceof FormField) {
if (!$field instanceof FormField) {
throw new InvalidArgumentException("$this->Type is not a FormField");
}
return $field;
Expand Down

0 comments on commit 19d6497

Please sign in to comment.