namespace app\models;
class Financing extends \yii\db\ActiveRecord
{
public function rules()
{
return [
[['Total_investment','Self_financing',"Financing_amount","Plan_bond"],'integer'],
['Plan_bond','validatePlan_bond','skipOnEmpty' => false, 'skipOnError' => false],
];
}
/*
*/
public function validatePlan_bond($attribute)
{
if( $this->Total_investment > 0
and $this->Self_financing >0
){
//在不适用额外的js的情况下,将Plan_bond的值页面的表单元素中,
$this->Plan_bond = $this->Total_investment-$this->Self_financing-$this->Financing_amount;
}
}
}
}