I am extending form_helper that will populate data from an array in view.
E.g:
//Controller - user_controller.php
User_Controller extends CI_Controller{
function edit(){
$data['record'] = array('username'=>'robert','email'=>'[email protected]');
$this->load->view('edit',$data);
}
}
//View - edit.php
<?= $record['username']; ?> >> 'robert'
<?= simple_input('halo'); ?>
//Helper - MY_form_helper.php
function simple_input($name){
var_dump($record); >> Undefined variable: record
return "<input type='text'/>";
}
I thought helper should load up the variables from view. Didn't really understand how it works. How can I access the view variables from helper?