使用Yii2更新图像时,我遇到验证问题.它总是要求我上传图像.但我不想要这个.始终无需更新图像.
我试过skipOnEmpty但它不能正常工作它会在上传照片时产生效果,这也是不正确的.
请帮忙!!
模型
public function rules()
{
return [
[['carid', 'name'], 'required'],
[['carid', 'coverphoto', 'status'], 'integer'],
[['name'], 'string', 'max' => 200],
[['imageFiles'], 'image','extensions' => 'png, jpg, jpeg, gif', 'maxFiles' => 4, 'minWidth' => 100, 'maxWidth' => 800, 'minHeight' => 100, 'maxHeight'=>600,'skipOnEmpty' => true],
];
}
Run Code Online (Sandbox Code Playgroud)
调节器
public function actionUpdate($id)
{
$model = $this->findModel($id);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->photoid]);
} else {
return $this->render('update', [
'model' => $model,
]);
}
}
Run Code Online (Sandbox Code Playgroud) 我是Yii2的新手.请帮我实现这个目标.我想知道如何在yii2中创建absoluteurl.我已经尝试了下面给出的代码,但我想要一些不同的东西.
echo Yii::$app->urlManager->createAbsoluteUrl(['site/confirm', 'id' => $user->id,'code' => $user->token,'&']);
output is http://car-rental.demoinja.com/site/confirm/69?code=275a9253dfc81efa47be4fdf1fc6a927&1=%26
Run Code Online (Sandbox Code Playgroud)
但我想要这样的网址
http://car-rental.demoinja.com/site/confirm/?id=69&code=275a9253dfc81efa47be4fdf1fc6a927
Run Code Online (Sandbox Code Playgroud)