Better exception handling for PopoverField

This commit is contained in:
Ingo Schommer 2016-08-28 13:45:16 +12:00
parent bd9997f79a
commit 52686aa4ad

View File

@ -26,7 +26,8 @@ class PopoverField extends FieldGroup
protected $popoverTitle = null; protected $popoverTitle = null;
/** /**
* Placement of the popup box * Placement of the popup box, relative to the element triggering it.
* Valid values: bottom, top, left, right.
* *
* @var string * @var string
*/ */
@ -68,9 +69,14 @@ class PopoverField extends FieldGroup
{ {
$valid = ['top', 'right', 'bottom', 'left']; $valid = ['top', 'right', 'bottom', 'left'];
if (in_array($placement, $valid)) { if (!in_array($placement, $valid)) {
$this->placement = $placement; throw new InvalidArgumentException(
'Invalid placement value. Valid: top, left, bottom, right'
);
} }
$this->placement = $placement;
return $this; return $this;
} }