Can't access post->input() from autoloaded Config files |
[eluser]heat23[/eluser]
My site has many pages and forms so I wanted to globalize some of the shared forum input attributes. For example.. I would want to put the following array declaration in some helper/config file so that I can access it from a view like: form_input($username_input) Code: $username_input = array( I tried creating a custom config file and placing it in the /config dir and included the line $this->CI =& get_instance(); at the top, however, if the form has an error, it is not setting the POST value. Does anyone know how to either 1) Fix this above scenario so I can access input->post() from a config file 2) Suggest a better method for globalizing form attributes
[eluser]Colin Williams[/eluser]
Everybody sing it with me: "MY_Controller, MY_Controller. Anything is possible with MY_Controller..." That's as far as I've gotten with the song.
[eluser]heat23[/eluser]
Can you please be more specific on how I would set something like this up using MY_Controller?
[eluser]Kamape[/eluser]
Are you sure you can use instance-dependant variables in config files? ($this->CI). Why not just use $CI =& get_instance(); Else you can always var_dump($this->CI->input) or something like that to find out whether you have an instance.
[eluser]Kamape[/eluser]
MY_Controller is to extend the usual Controller class in your library folder with a user-created class called MY_Controller which lays in the file MY_Controller.php. Example: class MY_Controller extends Controller { //Do som fluffy code-work with you global-form-specific-code here }
[eluser]Dam1an[/eluser]
[quote author="Colin Williams" date="1246926120"]Everybody sing it with me: "MY_Controller, MY_Controller. Anything is possible with MY_Controller..." That's as far as I've gotten with the song.[/quote] Haha! What melody is that supposed to be? Cause I can't seem to get it right We could make a whole song, where each line is a solution to a problem, make it a community effort where everyone adds a line
[eluser]Kamape[/eluser]
[quote author="Dam1an" date="1246926788"][quote author="Colin Williams" date="1246926120"]Everybody sing it with me: "MY_Controller, MY_Controller. Anything is possible with MY_Controller..." That's as far as I've gotten with the song.[/quote] Haha! What melody is that supposed to be? Cause I can't seem to get it right We could make a whole song, where each line is a solution to a problem, make it a community effort where everyone adds a line[/quote] Just picked up the guitar, trying to get some nice chords to fit in. :-)
[eluser]heat23[/eluser]
How do I progammatically call the array in MY_Controller that contains the attributes for the form field
[eluser]Kamape[/eluser]
Everything in MY_Controller is accessible in your Controllers 'cause overriding a framework class is practically extending that class. Read more here: http://ellislab.com/codeigniter/user-gui...aries.html
[eluser]Colin Williams[/eluser]
Quote:Haha! What melody is that supposed to be? Cause I can’t seem to get it right I'm thinking sort of showtunes-y, with big band backing it up. Or maybe we could adapt "My Sharona" Quote:Just picked up the guitar, trying to get some nice chords to fit in. Ha! Awesome. But back to our regularly scheduled programming (see what I did there?) Here's some code for ya: Code: class MY_Controller extends Controller { |
Welcome Guest, Not a member yet? Register Sign In |