Creating scenario fails

hi guys,

following scenario will be implemented without any problems:





 //definiere ein Szenario mit folgenden Regeln:

[['id_kontakt_verwendungszweck', 'id_laenderkennung', 'standard', 'aktiv', 'vorwahl', 'telefonnummer'], 'required', 'on' => 'create_telefon'],

.

.

$model = new KontaktTelefon(['scenario' => 'create_telefon']);



Following scenario won’t be implemented without any problems:It fails. I will get validation error:“Please load up file”

Any ideas how to implement scenario correctly in case of dummyAttributes like attachement?





[['attachement'], 'file', 'skipOnEmpty' => false, 'maxSize' => 10 * 1024000, 'tooBig' => 'Maximal erlaubte Dateigröße:10 MByte', 'maxFiles' => 10],

            //definiere ein Szenario mit folgenden Regeln:

 [['attachement'], 'file', 'skipOnEmpty' => true, 'maxSize' => 10 * 1024000, 'tooBig' => 'Maximal erlaubte Dateigröße:10 MByte', 'maxFiles' => 10, 'on' => 'create_dateianhang'],

.

.

$model_dateianhang = new Dateianhang(['scenario' => 'create_dateianhang']);



Hi,

Without ‘on’, the first rule will be applied to all scenarios including ‘create_dateianhang’.

You can specify ‘except’ for the first rule.




[['attachement'], 'file', 'skipOnEmpty' => false, ... 'except' => 'create_dateianhang''],

[['attachement'], 'file', 'skipOnEmpty' => true, ...  'on' => 'create_dateianhang'],



http://www.yiiframework.com/doc-2.0/yii-validators-validator.html#$except-detail

Thx a lot. Great job!

This thread can be closed as succesfully soved