Welcome Guest, Not a member yet? Register   Sign In
form_dropdown issues
#3

[eluser]helmy[/eluser]
I've looked over the user guide and these forums several times. I'm sure it's something simple and I'm over looking it. I'm using drop down box to edit the position an item shows up in a menu. I want the current position the item is to be the selected value. Here's what I currently have in my code.

Model:
Code:
###
# This will return an array with each page position.
###
function page_position_count($subject_id) {
  $page_set = $this->db->from('pages')->where('subject_id', $subject_id)->get();

  if($page_set->num_rows() > 0) {
   foreach ($page_set->result() as $page) {
    $data[$page->id] = $page->position;
   }
   return $data;
  }
}

View:
Code:
<p> Position: &lt;?php echo form_dropdown('position', $page_count, /* Mystical 3rd param */); ?&gt; </p>

Controller:
Code:
function edit_page($sel_subject = NULL, $sel_page = NULL) {
  $this->load->model('validate_model');
  $this->validate_model->confirm_logged_in();
  
  
  $header_data['title'] = 'Widget Corp: Edit Page';
  $data['subjects'] = $this->get_func_model->get_all_subjects();
  $data['pages'] = $this->get_func_model->get_pages_for_subject($sel_subject, false);
  $data['private_nav'] = $this->nav_model->private_navigation($sel_subject);
  $data['cur_page'] = $this->get_func_model->get_page_by_id($sel_page);
  $data['cur_subject'] = $this->uri->segment(3);

  //Passes the array of positions to the view
  $data['page_count'] = $this->get_func_model->page_position_count($sel_subject);
  
  $this->load->view('includes/header', $header_data);
  $this->load->view('edit_page_view', $data);
  $this->load->view('includes/footer');
}



Messages In This Thread
form_dropdown issues - by El Forum - 01-28-2012, 03:31 AM
form_dropdown issues - by El Forum - 01-28-2012, 03:39 AM
form_dropdown issues - by El Forum - 01-28-2012, 05:12 AM
form_dropdown issues - by El Forum - 01-28-2012, 07:49 AM



Theme © iAndrew 2016 - Forum software by © MyBB