I use Codeigniter 2.x and this is function in my controller:
Code:
$query = $this->users_mod->changeProductData($idPro);
$url = base_url();
$data = array(
'ap_heading' => 'Edit product',
'base_url' => base_url(),
'ap_entries' => $query,
'ap_product' => 'active',
'ap_username' => $this->session->userdata['logged']['username'],
'ap_content' => $this->load->view('editproduct', '', true)
);
$this->parser->parse('template', $data);
In template view I call another view with this method:
Code:
<div class="container-fluid main-body">
<?= $ap_content ?>
</div>
And on the end in view editproduct.php I list data in form.
But I have problem how to set value in form when form validation show some errors to still keep data in field. I done that like this before I start use parse:
Code:
<label class="radio-inline"><input type="radio" name="active" id="active1" value="0" class="radio" <?php if($row->active==0) { echo set_radio("active", "0", true); } else { echo set_radio("active", "0"); } ?>>inactive</label>
I have two question:
1. As you can see in template.php I can write php code and call variable (<?= $ap_content), but that doesn't work in view editproduct.php. Can I somehow use another variable from array in editproduct.php with php tag?
2. Can I somehow in controller in array write some variable with php code. For example:
'ap_var' = '<?php echo set_radio("active", "0", true); ?>'
and call that variable in editproduct.php as {ap_var}?