2
\$\begingroup\$

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>
\$\endgroup\$
2
\$\begingroup\$

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>
\$\endgroup\$
  • \$\begingroup\$ form_add_user is a large html form and I placed in another view for that reason. \$\endgroup\$ – AndreFontaine Jan 30 '14 at 16:07
  • \$\begingroup\$ Completely re-wrote answer after some research + your comment @AndreFontaine \$\endgroup\$ – Albzi Jan 30 '14 at 16:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.