Welcome Guest, Not a member yet? Register   Sign In
Why 2 successive $data = $this->model->func(); statements overlap?
#1

[eluser]EthanSP[/eluser]
Why do the $data values on the first $data = $this->model->func() call cannot be retrieved on my view file? I highlighted (in red) the variable ($base) that won't show up its value:

Controller:

function demographics() {
$this->load->helper('form');
$this->load->helper('html');
$this->load->model('bangungot_model');
if($this->input->post('mysubmit')) {
$this->bangungot_model->add_entry();
}
$data = $this->bangungot_model->get_paths();
$data = $this->bangungot_model->get_fields();

$this->load->view('demographics', $data);
}

Model:

function get_paths() {
$data['base'] = $this->config->item('base_url');
$data['custom_css'] = $this->config->item('custom_css');
$data['banner'] = $data['base'].'index.php/welcome/banner';
return $data;
}
function get_fields() {
$data['title'] = 'Demographics';
$data['fid'] = array('name'=>'id');
$data['ffn'] = array('name'=>'fname');
return $data;
}

View:

...
<link href="<?= "$base/$custom_css" ?>" rel="stylesheet" type="text/css">
...
<div class="jwin1">
&lt;?= heading($title,3);
echo form_open('books/input'); ?&gt;
</div>
...
<div class="jmenu">
<ul class="jdatacol"> &lt;!-- style="width:200px;" --&gt;
&lt;?= "<li>".form_input($fid)."</li>"; ... ?&gt;
<li><label>&lt;input type="radio" name="Sex" value="female" style="width: 12px;" /&gt; Female</label>
...
</ul>
</div>
<div class="jwin3">
&lt;? //&lt;input name="save" type="button" value="Save changes" class="jbutton" /&gt;</div>
echo form_submit('mysubmit','Submit!');
echo form_close(); ?&gt;
</div>
...
#2

[eluser]xwero[/eluser]
You are overwriting one array with the other. You have to do
Code:
$data = array_merge($this->bangungot_model->get_paths(),$this->bangungot_model->get_fields());
#3

[eluser]EthanSP[/eluser]
[quote author="xwero" date="1211548359"]You are overwriting one array with the other. You have to do
Code:
$data = array_merge($this->bangungot_model->get_paths(),$this->bangungot_model->get_fields());
[/quote]

Wow, it worked! You're a genius, xwero!!! Thank you very much for your time & for sharing a piece of your mind. Cheers to the CI community!
#4

[eluser]xwero[/eluser]
That wasn't genius that was basic programming knowledge.




Theme © iAndrew 2016 - Forum software by © MyBB