yii验证规则根据不同规则提示不同的错误

开始你的创作吧。

$rules[] = Model::addRule(\'category_sn\', \'category_name\', \'unique\', [  
			\'params\' => [  
				\'category_type\'  
			],   
			\'message\' => \'此类别{attribute}已存在\',  
			\'filter\' => [  
				\'and\',   
				[  
					\'=\',   
					\'is_deleted\',   
					0  
				],   
				[  
					\'=\',   
					\'category_type\',   
					$this->category_type  
				],  
			]  
		]);  

使用{attribute}属性