\$\begingroup\$
\$\endgroup\$
I'm calling a view into a view. Am I doing correctly, or is this a bad practice?
<div class="tab-pane" id="tab_1_2">
<div class="portlet ">
<div class="portlet-title">
<div class="caption">
<i class="icon-reorder"></i> Nuevo Usuario
</div>
</div>
<?php $this->load->view('modules/user/form_add_user'); ?>
</div>
</div>
syb0rg
21.9k10 gold badges113 silver badges192 bronze badges
asked Jan 30, 2014 at 15:17
1 Answer 1
\$\begingroup\$
\$\endgroup\$
2
For your controller, a method like this would be best to call all your variables:
$data = array(
"add_user" => $this->load->view('form_add_user'),
"username" => $username,
"admin" => $admin
);
(Variables are made up just for example)
Then, within your code, do this:
<div class="tab-pane" id="tab_1_2">
<div class="portlet ">
<div class="portlet-title">
<div class="caption">
<i class="icon-reorder"></i> Nuevo Usuario
</div>
</div>
<?=$add_user;?> <!-- looks cleaner -->
</div>
</div>
-
\$\begingroup\$ form_add_user is a large html form and I placed in another view for that reason. \$\endgroup\$AndreFontaine– AndreFontaine2014年01月30日 16:07:11 +00:00Commented Jan 30, 2014 at 16:07
-
\$\begingroup\$ Completely re-wrote answer after some research + your comment @AndreFontaine \$\endgroup\$Albzi– Albzi2014年01月30日 16:11:10 +00:00Commented Jan 30, 2014 at 16:11
lang-php