Если делать так:
Код: Выделить всё
['full_name', 'required', 'when' => function ($model) {
return $model->company_id == '';
}, 'whenClient' => "function (attribute, value) {
return $('#transfer-company_id').val() == '';
}"],
['company_id', 'required', 'when' => function ($model) {
return $model->full_name == '';
}, 'whenClient' => "function (attribute, value) {
return $('#transfer-full_name').val() == '';
}"],
Код: Выделить всё
[['full_name', 'company_id'], 'fill', 'skipOnEmpty'=> false],
public function fill($attribute_name, $params)
{
if (empty($this->company_id)
&& empty($this->full_name)
) {
$this->addError($attribute_name, Yii::t('app', 'At least 1 of the field must be filled up properly'));
return false;
}
return true;
}