Reputation: 177
In my Yii application i have a radio button. When the left button of the radio button is pressed, the value of field_B should not be bigger than 3999. Here is my code in my model.php (But it's not working):
[['field_B''], 'number', 'max' => 3999 , 'min' => 0000, 'tooBig'=> 'The Value is too big',
'when' => function ($model) {
return $model->Absatzart;
}, 'whenClient'=> new JsExpression("
function (attribute, value) {
return ((!$('#stornierung-absatzart').is(':checked')) && ($('#stornierung-absatzart').val()=='1'));
}")],
Upvotes: 0
Views: 687
Reputation: 4261
Try below
[['field_B'], 'number',
'max' => 3999 ,
'min' => 0000,
'tooBig'=> 'The Value is too big',
'when' => function ($model) {
return $model->Absatzart;
},
'whenClient'=> new JsExpression("
function (attribute, value) {
if ($('input[type=radio]:checked') =='1') {
return true;
}
return false;
}")
],
Upvotes: 1