I have a crud which shows the attached list. In the underlying table I have a field called 'active' which can be zero or one. Only one of the "active" fields can be set to 1 for any specific user (email address). The browsed sample data can be seen in the attached file. richb2x1@gmail.com has three campaigns. So the question is "how can I enforce only one of the 3 records for richb2x1@gmail.com to have a 1 in the 'active' field?" by using GC's fantastic features? I have a callback attached to the Make Active button. So I'd like to set 'active' on all three of those campaigns to zero when the Make Active button is pressed, and then afterwards set only one of them to 1. I will also need to change the text on the upper right to the active co's name, but that is a detail for later. For right now I just want to set the Active fields (for a specific email user) to zero. I was thinking I could use
$crud->callback_column('active',array($this,'add_field_callback_1'));
and use function add_field_callback_1(
set each 'active' field to zero
)
and then go back and set just the current one to 1.
I am not sure if this is the easiest way to do this in GC or CI. Can I use the set_rules to accomplish this? I am not sure if I will be setting the database fields or just setting the fields in "the list". In the example data, Microsoft is active.
Right now, when I press the "Make Active" button,
This call back gets called:
function company_update($primary_key , $row)
{
// $this->session->set_userdata('campaign',$row->company_division);
$string='Configure/update_current/'.$row->company_division;
return site_url($string);
}
which fires this url
function update_current($company)
{
redirect('Configure/campaign_management_with_actions'); //success
}
I redirect because otherwise the screen is blank.