[eluser]D_Williams[/eluser]
I've used my own libraries before with no problem, but for some reason this one is erroring out on me.
The library file is called "Form_elements.php" and located in my application/libraries folder. Its purpose is to provide a bunch of functions to output form elements I use often (such as selecting a client from our client list in this case).
The contents for it are below:
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Form_elements
{
private $CI;
function __construct()
{
$this->CI =& get_instance();
}
function ClientSelect($name)
{
$this->CI->load->model('client_model');
$clients = $this->CI->client_model->GetAllClients();
$output = "<select name=\"$name\">";
foreach($clients as $c)
$output .= "<option value=\"$c\" " . set_select($name, $c) . " >$c</option>";
$output .= '</select>';
return $output;
}
}
Now I have a view file trying to load this library and use it.
Here is the view file:
Code:
<?php
$this->load->library('form_elements');
echo form_open('utilities/batch_mail_sender');
?>
<label for="client">Client Name</label>
<?php echo $this->form_elements->ClientSelect('client'); ?>
</form>
When I load up that view, however, I get the following errors:
Code:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: CI_Loader::$form_elements
Filename: utilities/batch_mail_form.php
Line Number: 7
Fatal error: Call to a member function ClientSelect() on a non-object in /home/danny/workspace/OpenCollect/application/views/utilities/batch_mail_form.php on line 7
Am I doing something obviously wrong here?