Yii Framework Forum: Creating scenario fails - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Creating scenario fails [solved]

#1 User is offline   tklustig 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 419
  • Joined: 20-April 17
  • Location:Hannover

Posted 07 March 2018 - 06:35 PM

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']);

0

#2 User is offline   softark 

  • Keep It Simple
  • Yii
  • Group: Moderators
  • Posts: 3,642
  • Joined: 16-February 11
  • Location:Japan

Posted 08 March 2018 - 04:49 AM

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.yiiframew...#$except-detail
1

#3 User is offline   tklustig 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 419
  • Joined: 20-April 17
  • Location:Hannover

Posted 08 March 2018 - 08:10 AM

View Postsoftark, on 08 March 2018 - 04:49 AM, said:

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.yiiframew...#$except-detail

Thx a lot. Great job!
This thread can be closed as succesfully soved


0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users