Yii Framework Forum: ajax validation error - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

ajax validation error upload image is not working Rate Topic: -----

#1 User is offline   kotesh 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 29-June 12

Posted 29 June 2012 - 09:10 AM

in my project having upload image if i select image it goes to database with out select image if i click on create button validation is not working
contorller:
public function actionCreate()
{
$model=new Admission;

// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);

if(isset($_POST['Admission']))
{
$model->attributes=$_POST['Admission'];
$model->image=CUploadedFile::getInstance($model,'image');
if($model->save())
$model->image->saveAs(Yii::app()->basePath .'/images/' . $model->image);
//$model->image->saveAs(Yii::getPathOfAlias('webroot').'/files/'.$model->image);
$this->redirect(array('view','id'=>$model->studentid));
}

$this->render('create',array(
'model'=>$model,
));
}
model:
return array(
array('image', 'file', 'types'=>'jpg, gif, png'),
array('studentfname, studentlname, dateofjoining, class, course, dob, age, gender, previousinstitutename, Fathername, parentorguardian_occupation, relation_w_student, address, city, state, country, pincode, mobile, Relegion, category,image', 'required'),
}
in this controller if write save as function validation not working in form
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users