diff --git a/framework/yii/base/Model.php b/framework/yii/base/Model.php index 3e38442..553f2e8 100644 --- a/framework/yii/base/Model.php +++ b/framework/yii/base/Model.php @@ -583,10 +583,15 @@ class Model extends Component implements \IteratorAggregate, \ArrayAccess /** * Sets the scenario for the model. * @param string $value the scenario that this model is in. - * @see getScenario + * @throws InvalidParamException if the scenario to be set is unknown + * @see scenarios() */ public function setScenario($value) { + $scenarios = $this->scenarios(); + if (!isset($scenarios[$value])) { + throw new InvalidParamException("Setting unknown scenario: $value"); + } $this->_scenario = $value; }