/**
* @inheritdoc
*/
public function rules() {
return [
[['quantity', 'first_name', 'last_name', 'email', 'country', 'postal_code', 'locality', 'address'], 'required'],
[['quantity'], 'integer'],
[['first_name', 'last_name', 'email', 'country', 'phone'], 'string', 'max' => 127],
[['postal_code'], 'string', 'max' => 20],
[['locality', 'address'], 'string', 'max' => 255]
];
}
public function scenarios() {
return [
'firstStep' => ['quantity', 'first_name', 'last_name', 'email'],
'secondStep' => ['country', 'postal_code', 'locality', 'address', 'phone'],
];
}
當我提交表單,我得到:Yii的場景 - 驗證無法觸發
無效參數 - 警予\基地\ InvalidParamException
未知場景:默認
有誰知道爲什麼?也許這不是覆蓋方案方法的正確方法。
你只是檢查哪個字段是必需的或安全的,這一個定義.... – vishuB
Vishu帕特爾:不明白你的意見對不起。請謹慎澄清? – MEM