[eluser]BandonRandon[/eluser]
So I am extreamly new to CI. Also I'm actually using PyroCMS but the set up is the same. I am storing a value of my radio button in my database as a numeric value (1,2,3) I am trying to figure out how to pull that out when I go to edit the entry.
My View File has this
Code:
<li class="<?php echo alternator('', 'even'); ?>">
<label for="primary_phone"><?php echo lang('employee.primary_phone'); ?></label>
<input type="radio" name="primary_phone" value="work_phone" <?php echo set_radio('primary_phone[]', 'work_phone',$this->employee_m->get_employee_info($id,'primary_phone','work_phone'));?> /> <?php echo lang('employee.work_phone'); ?>
<input type="radio" name="primary_phone" value="home_phone" <?php echo set_radio('primary_phone[]', 'home_phone',$this->employee_m->get_employee_info($id,'primary_phone','home_phone')); ?> /> <?php echo lang('employee.home_phone'); ?>
<input type="radio" name="primary_phone" value="cell_phone" <?php echo set_radio('primary_phone[]', 'cell_phone',$this->employee_m->get_employee_info($id,'primary_phone','cell_phone')); ?> /> <?php echo lang('employee.cell_phone'); ?>
<p><?php echo lang('employee.primary_phone_desc'); ?></p>
</li>
In my module I have
Code:
public function get_employee_info($id,$info,$field='')
{
if($info == "primary_phone"){
$employee_info_query = $this->db->select('primary_phone')->from('database')->where('id', $id)->get();
$primary_phone_numeric= $employee_info_query->row()->primary_phone;
if(($primary_phone_numeric =='1') && ($field='work_phone')){ $employee_info = 'TRUE';}
elseif(($primary_phone_numeric =='2') && ($field='home_phone')){ $employee_info = 'TRUE';}
elseif(($primary_phone_numeric =='3') && ($field='cell_phone')){ $employee_info = 'TRUE';}
else {$employee_info = 'FALSE';}
}
}
The idea is if the field value is the correct name and the number matches the value to make it as true else mark it as false. Right now it seems no value is being passed to the view at all.