Error in Yii2: Model not inserted due to validation error.
1. Report an error in Yii2: Model Not Inserted Due to Validation Error. as shown in Figure 1
2. The code is implemented as follows
$input->value = $context->processDraft($value, $form, $field);
Yii::info(
[
'input' => $input->toArray()
],
'SurveyFormContentController.actionDraftUpdate',
);
if (!$input->save()) {
$transaction->rollBack();
return [
'code' => 10003,
'message' => '更新报名信息失败',
];
}
[
'input' => [
'id' => '1826803808485990',
'survey_form_id' => '1826803808485966',
'content_id' => '1826803808485988',
'field_id' => '1826803808485987',
'value' => 444,
],
]
3. However, !$input->save(false) does not report an error. Problem analysis, the value of value is 444 (integer), but the rule requires that value must be a string. You need to convert the value to a string.
$input->value = (string)$context->processDraft($value, $form, $field);
