Welcome Guest, Not a member yet? Register   Sign In
need autofill function in view
#2

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;
$data['last_name'] = $user_data->last_name;
$this->load->view("some_view"$data); 

Then in the view
PHP Code:
<?= form_input([
 
   'name' => 'first_name',
 
   'type' => 'text',
 
   'style' => 'text-transform:capitalize',
 
   'class' => 'form-control',
 
   'placeholder' => 'Enter your first name'], 
 
   'value' => set_value('first_name'$first_name)]); 
?>

Use the same idea for the last_name field.
PHP Code:
<?= form_input([
 
   'name' => 'last_name',
 
   'type' => 'text',
 
   'style' => 'text-transform:capitalize',
 
   'class' => 'form-control',
 
   'placeholder' => 'Enter your last name'], 
 
   'value' => set_value('last_name'$last_name)]);
?>
Reply


Messages In This Thread
need autofill function in view - by karthick - 05-21-2019, 02:30 AM
RE: need autofill function in view - by dave friend - 05-21-2019, 10:24 AM



Theme © iAndrew 2016 - Forum software by © MyBB