Welcome Guest, Not a member yet? Register   Sign In
Creating a form dropdown from db
#11

[eluser]laytone[/eluser]
What Template parser are you using? How / where do you send data to your views? that drop down options array needs to be include in your load->view like this:

Code:
$pagedata['dropdownoptions'] = $this->your_model->your_get_list_function();
$pagedata['examplevar'] = "hello world";
$this->load->view('view_name', $pagedata);

After this is done there is a variable called $dropdownoptions and a variable called $examplevar in your view.
#12

[eluser]Bionicjoe[/eluser]
Got all my template stuff from Simple Template

Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Template {
        var $template_data = array();
        
        function set($name, $value)
        {
            $this->template_data[$name] = $value;
        }
    
        function load($template = '', $view = '' , $view_data = array(), $return = FALSE)
        {              
            $this->CI =& get_instance();
            $this->set('contents', $this->CI->load->view($view, $view_data, TRUE));            
            return $this->CI->load->view($template, $this->template_data, $return);
        }
}

/* End of file Template.php */
/* Location: ./system/application/libraries/Template.php */
#13

[eluser]laytone[/eluser]
Everything looks good then.. make sure there is a $ in front of dropdownoptions

Quote:Added code. Same issue.

A PHP Error was encountered

Severity: Notice

Message: Undefined variable: dropdownoptions

Filename: views/addticket_view.php

Line Number: 2
#14

[eluser]laytone[/eluser]
Ok, here we go, I think I got it:

Code:
function addticket()
    {
        $this->template->set('title', 'Add ticket');
        $this->template->set('heading', 'Add Ticket');
        
        $this->load->model('outage_model');
        $viewdata['dropdownoptions'] = $this->outage_model->sitedropdown();
            
        $this->template->load('template', 'addticket_view', $viewdata);
    }

I bet that works
#15

[eluser]Bionicjoe[/eluser]
Beautiful!

You got it!!




Theme © iAndrew 2016 - Forum software by © MyBB