need autofill function in view - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: need autofill function in view (/showthread.php?tid=73672) |
need autofill function in view - karthick - 05-21-2019 I have some text boxes in my view like this: <?=form_input(['name'=>'last_name','type'=>'text','style'=>'text-transform:capitalize','class'=>'form-control','placeholder'=>'Enter your last name','value'=>set_value('last_name')])?> i have a database table 'userlogin' which has a field 'last_name' when I am entering the value in the last_name field, i want autofill function in it with all the values from 'last_name' field in database. How do i do this? RE: need autofill function in view - dave friend - 05-21-2019 The easiest way is to gather all the field data you need in the controller and then pass it to the view. Assuming the controller calls a model that returns a $user_data object like this PHP Code: $data['first_name'] = $user_data->first_name; Then in the view PHP Code: <?= form_input([ Use the same idea for the last_name field. PHP Code: <?= form_input([ |