Using the country dropdown helper |
[eluser]invision[/eluser]
Hi, I'd like to use the following: http://codeigniter.com/wiki/helper_dropd...ntry_code/ in a form. How do I achieve this? Where does the Helper go? Thank you.
[eluser]invision[/eluser]
Thanks for the reply. I'm a little unsure how to use it. Should I have country_helper.php as: Code: <?php and my View as : Code: echo country_dropdown('country'); and my Controller as : Code: $this->load->helper(array('form', 'url', 'country')); Thanks for any help with this
[eluser]smilie[/eluser]
Hi, By looking at the code, I would say that that is correct. I did not test it however Basically, helper files are 'simple' functions that do something. Once you load helper (which you do in controller and / or view) you can access all functions from that helper. I would say - try and see what happens Cheers, Smilie
[eluser]invision[/eluser]
Hi Smilie Thanks for the quick reply. I tried this exact setup, but got: Code: A PHP Error was encountered Any ideas? 256 is this line: foreach($countries as $key => $country) { Thank you
[eluser]smilie[/eluser]
Ah, I see. Just place $config['country_list'] = array (...) WITHIN the function itself When it is outside the function, function does not know about it Let me know if that worked Cheers, Smilie
[eluser]invision[/eluser]
Thanks for the reply. I have now moved the array within the function but get the same error :'(
[eluser]smilie[/eluser]
Hm, according to this thread: http://ellislab.com/forums/viewthread/141730/ it should work... Only difference I see is that they have named it MY_form_helper.php :S Do not know if that MY_ does some magic or not. You could try to move complete $config[] array to application/config/config.php Cheers, Smilie
[eluser]invision[/eluser]
Wow, that did the trick! I moved the $config[] to config.php and it now works Many thanks Smilie
[eluser]smilie[/eluser]
Sure no problem. Should tho' work in the function itself. As creator of this helper said in other topic, they did not want to 'overload' the config.php with such long array Have fun! Cheers, Smilie |
Welcome Guest, Not a member yet? Register Sign In |