As an easy way out, just set up separate verification messages for the required attributes:
$model = DynamicModel::validateData(compact('name','shipping'), [
[['name'], 'required', ['message' => Yii::t('app', 'Name is required for this form.')]],
[['name'], 'required', ['message' => Yii::t('app', 'Shipping address is required for this form.')]],
]);
And use labels when displaying the DynamicModel field:
echo $form->field($model, 'name')->textInput()->label(Yii::t('app', 'Name'));
echo $form->field($model, 'name')->textInput()->label(Yii::t('app', 'Shipping address'));
source
share