好的,所以我尝试允许用户使用此代码通过管理面板更改密码,但我不断收到
ORM_Validation_Exception [0]:无法验证数组 ~ MODPATH/orm/classes/kohana/orm.php [1174]
任何人有任何解决方案?这里分别是控制器功能和模型功能和视图
控制器:
public function action_edituser() {
$this->auto_render = false;
$edit = Model::factory('manageusers');
$post = $_POST;
$edit->editUser($post);
}
模型:
public function editUser($array) {
try {
$user = ORM::factory('user')
->where('id', '=', $array['id'])
->find()
->update_user($array, array(
'username',
'password',
'email',
));
return $this->response('success', 'User Edited');
} catch (Database_Exception $e) {
$this->response('error', $e->getMessage());
}
}
看法:
<div class="modal" id="editmodal" style="display: none;">
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h3>Edit User</h3>
</div>
<div class="modal-body">
<?php
echo Form::open('admin/manageusers/edituser', array('data-function'=> '/admin/manageusers/updategrid', 'data-element' => 'tbody'));
echo Form::label('username', 'Username');
echo Form::input('username', null, array('id' => 'username'));
echo Form::label('email', 'Email');
echo Form::input('email', null, array('id' => 'email'));
echo HTML::anchor('#', 'Change Password', array('id' => 'changepass', 'style' => 'display: block;'));
echo '<div id="passwordchange" style="display: none;">';
echo Form::label('password', 'Password');
echo Form::password('password', null, array('id' => 'password'));
echo Form::label('password_confirm', 'Confirm Password');
echo Form::password('password_confirm');
echo '</div>';
echo Form::hidden('id', null, array('id' => 'id'));
?>
</div>
<div class="modal-footer">
<a href="#" class="btn" data-dismiss="modal">Close</a>
<input type="submit" class="btn btn-success" value="Save changes" />
</div>
<?php echo Form::close(); ?>
</div>