Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function action_update($id)
- {
- $tpl = Haml::Factory('admin/users/create');
- $user = ORM::Factory('user', (int) $id);
- $data = array(
- 'username', 'mail', 'birthdate'
- );
- if($_POST)
- {
- foreach($data as $field)
- {
- $user->$field = $_POST[$field];
- }
- if(!empty($_POST['password']))
- {
- var_dump($_POST);
- $user->password = $_POST['password'];
- }
- $user->birthdate = date("Y-m-d", strtotime($_POST['birthdate']));
- if($user->check())
- {
- $user->save();
- }
- else
- {
- $tpl->set('errors', $user->validate()->errors('form/user'));
- $tpl->set($_POST);
- }
- }
- $tpl->set($user->as_array());
- $this->request->response = $tpl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement