I'm developing a project with Parse + CodeIgniter. I have two screens to manage ParseUsers: allUsers.php, that list all users. And detailUser.php, that create/edit a user.
When user submit a form (new ParseUser), i call save method. That contains the code:
try{
if ($user_id)
$user->save(true); // Update
else
$user->signUp(); // Insert
$this->session->set_flashdata('success', 'Success');
redirect('all-users');
}
catch(Parse\ParseException $error){
$error_message = $error->getMessage();
$this->session->set_flashdata('error', 'Error: ' . $error_message);
$this->data['user'] = $user;
$this->view = 'user/userDetail';
}
And at view, I have this (example user's name):
<input type="text" id="name" name="name" class="form-control" required value="<?php if(isset($user)): echo $user->name; endif;?>">
The form maintain the fields filled correctly, but the flashdata it's empty, if I refresh the page, than the flashdata appears. So, I after a search I found people saying that flashdata just works with redirect.
If I redirect my page, the flashdata appears. But, the fields are not filled.
I read about set_value, that is the correct way to maintain the fields? But, I like to have just two views, one to list all and another create/edit users. So, if I use the set_value, this is possible? What is the best practice?