我的问题是比较验证工作不正常.如果我min_bid_amount = 100
和min_buy_amount=1000
,它的工作.但是当min_bid_amount = 500
和时出现问题min_buy_amount=1000
.它还给了我错误信息.
这是我的模型规则
public function rules() { return [ [['min_bid_amount','min_buy_amount'], 'number'], ['min_buy_amount', 'compare','compareAttribute'=>'min_bid_amount','operator'=>'>', 'message'=>'Buying amount should be bigger than bid amount'], [['auction_start_date', 'auction_end_date', 'created'], 'safe'], [['id_product','min_bid_amount','min_buy_amount'], 'required'] ]; }
任何帮助将非常感谢.我认为JS不会将其转换为int类型值.那我该怎么办呢?
您应该将验证类型更改为number
:
['min_buy_amount', 'compare','compareAttribute'=>'min_bid_amount','operator'=>'>', 'message'=>'Buying amount should be bigger than bid amount', 'type' => 'number'],