scenarios() public method

An active attribute is one that is subject to validation in the current scenario. The returned array should be in the following format: php [ 'scenario1' => ['attribute11', 'attribute12', ...], 'scenario2' => ['attribute21', 'attribute22', ...], ... ] By default, an active attribute is considered safe and can be massively assigned. If an attribute should NOT be massively assigned (thus considered unsafe), please prefix the attribute with an exclamation character (e.g. '!rank'). The default implementation of this method will return all scenarios found in the Model::rules declaration. A special scenario named [[SCENARIO_DEFAULT]] will contain all attributes found in the Model::rules. Each scenario will be associated with the attributes that are being validated by the validation rules that apply to the scenario.
public scenarios ( ) : array
return array a list of scenarios and the corresponding active attributes.
Example #1
0
 public function scenarios()
 {
     $scenarios = parent::scenarios();
     $scenarios['login'] = ['username', 'password', 'verifyCode'];
     $scenarios['reg'] = ['username', 'password', 'verifyCode', 'confirmPassword'];
     return $scenarios;
 }
Example #2
0
 public function scenarios()
 {
     $scenarions = parent::scenarios();
     $scenarions[self::SCENARION_FULLINFO] = ['username', 'email', 'password'];
     $scenarions[self::SCENARION_ONLYEMAIL] = ['email'];
     return $scenarions;
 }
Example #3
0
 public function scenarios()
 {
     $scenarios = parent::scenarios();
     $scenarios[self::SCENARIO_AVATAR] = ['file'];
     $scenarios[self::SCENARIO_UPLOAD] = ['files'];
     return $scenarios;
 }
Example #4
0
 public function scenarios()
 {
     $scenarios = parent::scenarios();
     $scenarios[self::SCENARIO_LOGIN] = ['email', 'password'];
     $scenarios[self::SCENARIO_LOGIN_CAPTCHA] = ['email', 'password', 'captcha'];
     return $scenarios;
 }
 public function scenarios()
 {
     $scenarios = parent::scenarios();
     $scenarios['discharge'] = ['Money'];
     $scenarios['charge'] = ['Money'];
     return $scenarios;
 }
Example #6
0
 /**
  * @inheritdoc
  */
 public function scenarios()
 {
     $scenarios = parent::scenarios();
     $scenarios['default'] = ['username', 'password', 'rememberMe'];
     $scenarios['error'] = ['username', 'password', 'rememberMe', 'verifyCode'];
     return $scenarios;
 }
Example #7
0
 public function scenarios()
 {
     $scenarios = parent::scenarios();
     $scenarios['jur-validate'] = ['name', 'phone', 'address_reg', 'address_fact', 'inn', 'kpp', 'ogrn', 'r_sch', 'k_sch', 'bik', 'okpo', 'director', 'bank', 'city_id', 'experience'];
     $scenarios['client-validate'] = ['name', 'phone', 'address_reg', 'address_fact', 'inn', 'kpp', 'ogrn', 'r_sch', 'k_sch', 'bik', 'okpo', 'director', 'bank', 'city_id', 'experience'];
     return $scenarios;
 }
Example #8
0
 public function scenarios()
 {
     $scenarios = parent::scenarios();
     $scenarios['user'] = ['firstname', 'lastname', 'email', 'phone', 'password', 'confirmPassword'];
     $scenarios['company'] = ['name', 'category_id', 'email', 'phone', 'description', 'password', 'confirmPassword'];
     return $scenarios;
 }
Example #9
0
 public function scenarios()
 {
     $scenarios = parent::scenarios();
     $scenarios[self::SCENARIO_EDIT] = ['email', 'status', '!username', '!id'];
     $scenarios[self::SCENARIO_RESET_PWD] = ['password'];
     return $scenarios;
 }
Example #10
0
 public function scenarios()
 {
     $scenarios = parent::scenarios();
     $scenarios[self::SCENARIO_CREATE] = ['login', 'name', 'language', 'email', 'dateFormat', 'timeFormat', 'timeZone', 'newPass', 'newPassConfirm'];
     $scenarios[self::SCENARIO_UPDATE] = ['login', 'name', 'language', 'email', 'dateFormat', 'timeFormat', 'timeZone', 'newPass', 'newPassConfirm', 'isChangedPass'];
     $scenarios[self::SCENARIO_UPDATE_ACCOUNT] = ['name', 'language', 'email', 'dateFormat', 'timeFormat', 'timeZone', 'newPass', 'newPassConfirm', 'currentPass', 'isChangedPass'];
     return $scenarios;
 }
Example #11
0
 public function scenarios()
 {
     $scenarios = parent::scenarios();
     $scenarios['search'] = ['name', 'description', 'rule_name'];
     $scenarios['create'] = ['name', 'description', 'rule_name', 'data'];
     $scenarios['update'] = ['name', 'description', 'rule_name', 'data'];
     return $scenarios;
 }
Example #12
0
 public function scenarios()
 {
     $scenarios = parent::scenarios();
     $scenarios['sendImage'] = ['name', 'subject', 'email', 'phone', 'body', 'attachments'];
     $scenarios['order'] = ['subject', 'name', 'email', 'phone', 'body', 'verifyCode'];
     $scenarios['feedback'] = ['name', 'subject', 'email', 'body', 'verifyCode'];
     return $scenarios;
 }
Example #13
0
 public function scenarios()
 {
     $scenarios = parent::scenarios();
     /*$scenarios['short_register'] = ['username', 'email'];
       $scenarios['short_register2'] = ['username', 'email', 'password'];
       $scenarios['short_register3'] = ['email', 'password'];*/
     return $scenarios;
 }
Example #14
0
 /**
  * @inheritdoc
  */
 public function scenarios()
 {
     $scenarios = parent::scenarios();
     foreach ($this->_behaviors as $name) {
         if (($behavior = $this->getBehavior($name)) instanceof \nineinchnick\usr\components\FormModelBehavior) {
             $scenarios = array_merge($scenarios, array_fill_keys($behavior->scenarios(), $scenarios[self::SCENARIO_DEFAULT]));
         }
     }
     return $scenarios;
 }
Example #15
0
File: _Base.php Project: semnt/tp01
 public function scenarios()
 {
     $scenarios = parent::scenarios();
     if (!array_key_exists('create', $scenarios)) {
         $scenarios['create'] = $scenarios['default'];
     }
     if (!array_key_exists('update', $scenarios)) {
         $scenarios['update'] = $scenarios['default'];
     }
     return $scenarios;
 }
 public function scenarios()
 {
     $scenarios = parent::scenarios();
     $excepts = [];
     switch ($this->type) {
         case "sqlite":
             $excepts = ['user', 'dbname', 'port', 'prefix', 'password', 'createdb'];
             break;
     }
     foreach ($excepts as $index => $except) {
         $key = array_search($except, $scenarios['default']);
         unset($scenarios['default'][$key]);
     }
     return $scenarios;
 }
Example #17
0
 public function scenarios()
 {
     return array_merge(Model::scenarios(), ['new' => ['users', 'subject', 'content', 'content', 'category_id'], 'reply' => ['content', 'message_id'], 'search' => ['_id', 'users', 'subject', 'content', 'created_at', 'created_by', 'message_id', 'category_id']]);
 }
Example #18
0
 /**
  * @inheritdoc
  */
 public function scenarios()
 {
     return parent::scenarios();
 }
Example #19
0
 public function scenarios()
 {
     $scenarios = parent::scenarios();
     $scenarios['photo'] = ['file'];
     return $scenarios;
 }
Example #20
0
 /**
  * @inheritdoc
  */
 public function scenarios()
 {
     // bypass parent scenarios
     return Model::scenarios();
 }
Example #21
0
 /**
  * @inheritdoc
  */
 public function scenarios()
 {
     // bypass scenarios() implementation in the parent class
     return ArrayHelper::merge(Model::scenarios(), [self::SCENARIO_CATALOG => ['title', 'brand_id']]);
 }
Example #22
0
 /**
  * @inheritdoc
  */
 public function scenarios()
 {
     return [$this::SCENARIO_WITH_CAPTCHA => ['username', 'email', 'password', 'verifyCode']] + parent::scenarios();
 }
 /**
  * @inheritdoc
  */
 public function scenarios()
 {
     $scenarios = parent::scenarios();
     $scenarios[self::SCENARIO_VERIFY_EMAIL] = ['email'];
     return $scenarios;
 }
Example #24
0
 public function scenarios()
 {
     $scenarios = parent::scenarios();
     $scenarios['readonly'] = [];
     return $scenarios;
 }
Example #25
0
 /**
  * @inheritdoc
  */
 public function scenarios()
 {
     $scenarios = parent::scenarios();
     $scenarios[self::SCENARIO_DELETE] = ['Ref'];
     return $scenarios;
 }
Example #26
0
 /** @inheritdoc */
 public function scenarios()
 {
     $scenarios = parent::scenarios();
     return ArrayHelper::merge($scenarios, ['request' => ['email'], 'reset' => ['password']]);
 }
Example #27
0
 public function scenarios()
 {
     return array_merge(Model::scenarios(), ['search' => ['_id', 'date_time'], 'default' => ['_id', 'date_time']]);
 }
 public function scenarios()
 {
     return Model::scenarios();
 }
 /**
  * @inheritdoc
  */
 public function scenarios()
 {
     // bypass scenarios() implementation in the parent class
     return Model::scenarios();
 }
Example #30
0
 /**
  * 场景设置
  * @see \yii\base\Model::scenarios()
  */
 public function scenarios()
 {
     $scenarios = [self::SCENARIOS_CREATE => ['name', 'type', 'description'], self::SCENARIOS_DELETE => ['name']];
     return array_merge(parent::scenarios(), $scenarios);
 }