Welcome Guest, Not a member yet? Register   Sign In
Repopulating Form being displayed through Jquery UI tabs interface
#4

[eluser]Timothy_[/eluser]
Hello,

The code is nothing special or out of the ordinary.

Here is a simplified controller I quickly put together:

Code:
function edit()
{
    //get values for the form from the database
    $this->db->select('id, name, street, suburb, state')->from('myusers')->where('id', $user_id);
    $data['get_values'] = $this->db->get();
    
    //then pack them up here
    $this->load->vars($data);
    
    //now load the view
    $this->load->view('edit_form');

}


function edit_process()
{

    $this->load->library('form_validation');
    $this->form_validation->set_rules('id', 'id', 'required');
    $this->form_validation->set_rules('name', 'name', 'required');
    $this->form_validation->set_rules('street', 'street');
    $this->form_validation->set_rules('suburb', 'suburb');
    $this->form_validation->set_rules('state', 'state');

    if ($this->form_validation->run() == FALSE)
    {
    
    $errors = validation_errors();
    $this->session->set_flashdata('message', $errors);
    redirect('user/edit');
    
    } else {
    
    //Insert Data here.
    
    }

}

And my view file for the edit form
Code:
<?php if($get_values->result_array()) { ?>
    <?php foreach($get_values->result_array() as $row): ?>
    
    <?php echo form_open('user/edit_process/'); ?>

    <input type="hidden" name="id" value="<?php echo set_value('id', $row['id']; ?>" />

    <input type="text" name="name" value="<?php echo set_value('name', $row['name']); ?>" />

    <input type="text" name="street" value="<?php echo set_value('street', $row['street']); ?>" />

    <input type="text" name="suburb" value="<?php echo set_value('suburb', $row['suburb']); ?>" />

    <input type="text" name="state" value="<?php echo set_value('state', $row['state']); ?>" />

    </form>
    
    <?php endforeach; ?>
<?php } ?>

And my view file for the page that loads the edit form into the tabs
Code:
[removed]
function() {
    $('#tabs').tabs();
}
[removed]
<?php echo $this->session->flashdata('message');?>
<div id="tabs">
<ul>
    <li><a href="/">Home</li>
    <li><a href="/user/edit">Edit</a></li>
</ul>
</div>


As you can see there is nothing to exotic about the code. The problem is getting these post values back to the edit function in the user controller.

Hope someone can help.

Tim


Messages In This Thread
Repopulating Form being displayed through Jquery UI tabs interface - by El Forum - 02-17-2011, 08:43 PM



Theme © iAndrew 2016 - Forum software by © MyBB