How to use Helper function on view - CI4? |
On CI-3, when I've loaded helpers through autoload, I can use any function as well on view wihtout defining it on controller first.
I've read the ci4 docs, that loaded helper via base controller then extent any controller to it. But however. I call it on controller and assign to variable before use it on View. How can I use helper function on View directly?
Yes, you can use helper functions in view. For example there are the form helper, that's the one I use the most.
In your view file just call helper() function.
for example if you want to use form helper in view and you didn't define it in controller just do this in view: PHP Code: <?php helper('form'); ?> once you do this all functions inside form helper will be enabled to use directly in view. if you want to load more than one helper, you can do this PHP Code: <?php helper(['form', 'text']); ?> |
Welcome Guest, Not a member yet? Register Sign In |