[eluser]jaswinder_rana[/eluser]
Code
Code:
//Edit User Profile
function user_profile()
{
if ($this->dx_auth->is_logged_in())
{
$this->load->library('Validation');
$this->_validation_profile();
if ($this->validation->run() !== FALSE){
$data['user_id'] = $this->dx_auth->get_user_id();
$data['id_country'] = $this->input->post('id_country');
$data['website'] = $this->input->post('website');
}else{
//get User Profile data from database
$query = $this->user_profile->get_profile($this->dx_auth->get_user_id());
$obj = $query->result();
$data['id_country'] = $obj[0]->id_country;
$data['website'] = $obj[0]->website;
}
$data['countries'] = $this->_get_countries();
$this->load->view('auth/user_profile',$data);
}
}
// --------------------------------------------------------------------
function _validation_profile()
{
$rules['id_country'] = 'required|numeric';//'trim|required|htmlspecialchars|max_length[12]|alpha_dash';
$rules['website'] = 'trim|htmlspecialchars';//'trim|htmlspecialchars|callback_dateIssued';
$this->validation->set_rules($rules);
$fields['id_country'] = $this->lang->line('site_id_country');
$fields['website'] = $this->lang->line('site_website');
$this->validation->set_fields($fields);
$this->validation->set_error_delimiters('<span class="error">', '</span>');
}
Then my form is (Not sure if I am doing it the proper way
Code:
<?php $this->load->view('header');?>
<?php
if(!$this->dx_auth->is_logged_in()){
redirect('');
}
$id_country = set_value('id_country',$id_country);
$arr = array();
foreach($countries as $key=>$value){
$arr[$value->id] = $value->name;
}
$website = array(
'name' => 'website',
'id' => 'website',
'size' => 50,
'value' => set_value('website',$website)
);
?>
<h1><?php echo $this->lang->line('site_user_profile');?></h1>
<fieldset>
<legend>User Profile</legend>
<?php echo form_open('auth/user_profile'); ?>
<?php echo $this->dx_auth->get_auth_error(); ?>
<dl>
<dt><?php echo form_label('Country', 'country'); ?></dt>
<dd>
<?php echo form_dropdown('id_country',$arr,$id_country); ?>
<?php echo form_error('id_country'); ?>
</dd>
<dt><?php echo form_label('Website', $website['id']); ?></dt>
<dd>
<?php echo form_input($website); ?>
<?php echo form_error($website['name']); ?>
</dd>
<dt></dt>
<dd><?php echo form_submit('update', 'Update Profile'); ?></dd>
</dl>
<?php echo form_close(); ?>
</fieldset>
<?php $this->load->view('footer');?>
It's populating because I am using $this->input->post(). If I try to do an echo on top of my view, it doesn't work.
Code:
echo set_value('id_country');
Thanks