hello…
i have a question about how to update profile page using ajax
this is my controller(MainController.php)
public function actionProfile() {
//get current user dept id
$dept_id = Yii::app()->user->profile->dept_id;
//get department model
$DeptModel = Department::model()->findByPk($dept_id);
$dept_name = $DeptModel->dept_name;
//get current user role id
$role_id = Yii::app()->user->profile->role_id;
//get role model
$RoleModel = Role::model()->findByPk($role_id);
$role_name = $RoleModel->role_name;
$this->render('profile-page', compact("title", "dept_name", "role_name", "ic_no"));
}
and this is my view(profile-page.php)
<div class="tile-body tab-content rounded-bottom-corners">
<?php
$form = $this->beginWidget('CActiveForm', array(
'id'=>'form', //form-id
'enableAjaxValidation'=>true,
'clientOptions'=>array(
'validateOnSubmit'=>true,
),
));
?>
<!-- Tab panes -->
<div id="profile-tab" class="tab-pane fade in active">
<form>
<div class="row">
<div class="form-group col-md-12 legend">
<h4><strong>Personal</strong> Settings</h4>
<p>Your personal account settings</p>
</div>
</div>
<!--form 1-->
<div class="row">
<div class="form-group col-sm-12">
<label for="first-name">Name</label>
<input type="text" class="form-control" id="name" placeholder="<?= Yii::app()->user->profile->user_name ?>">
</div>
</div>
<!--form 2-->
<div class="row">
<div class="form-group col-sm-6">
<label for="user_nric">Ic Number</label>
<input type="text" class="form-control" id="ic_no" placeholder="<?= Yii::app()->user->profile->user_nric ?>">
</div>
<div class="form-group col-sm-6">
<label for="staff_no">Staff No</label>
<input type="text" class="form-control" id="zip" placeholder="<?= Yii::app()->user->profile->staff_no ?>">
</div>
</div>
<!--form 5-->
<div class="row">
<div class="form-group col-sm-6">
<label for="email">E-mail</label>
<input type="text" class="form-control" id="email" placeholder="<?= Yii::app()->user->profile->user_email ?>">
</div>
<div class="form-group col-sm-6">
<label for="contact_no">Contact No</label>
<input type="text" class="form-control" id="phone" placeholder="<?= Yii::app()->user->profile->user_contact_no ?>">
</div>
</div>
<!--form 6-->
<div class="row">
<div class="form-group col-sm-6">
<label for="avatar">Profile Image</label>
<div class="input-group">
<span class="input-group-btn">
<span class="btn btn-primary btn-file">
<i class="fa fa-upload"></i><input type="file" multiple="">
</span>
</span>
<input type="text" class="form-control" readonly="" id="profile image">
</div>
<span class="help-block">Allowed files: gif, png, jpg. Max file size 1Mb</span>
</div>
</div>
<!--form 7-->
<label for="bio">Bio</label>
<div class="profile-form">
<textarea class="form-control" placeholder="Say something?" rows="5"></textarea>
<div class="post-toolbar">
<a href="#" title="Add File"><i class="fa fa-paperclip"></i></a>
<a href="#" title="Add Image"><i class="fa fa-camera"></i></a>
</div>
</div>
<!--form 8-->
<div class="row">
<div class="col-sm-offset-4 col-sm-8">
<button type="save" name="save" class="btn btn-greensea">Save</button>
<button type="reset" class="btn btn-red">Reset</button>
</div>
</div>
</form>
</div>
But these codes can’t save data to database. Any wrong ?
can anybody can teach me?
and what the correct coding that i must put?
this my output