[eluser]debow[/eluser]
I have a form that post data most which is required. I'm wanting to time stamp each insert with just a year stamp. I have the insert working without the year stamp and I'm having issue try to figure out where I specify the date value and insert it with the same insert as the other form data.
Controller content is below.
Code:
function add()
{
// Validate form
$this->form_validation->set_rules('firstname', 'firstname', 'trim|required');
$this->form_validation->set_rules('lastname', 'lastname', 'trim|required');
$this->form_validation->set_rules('name', 'name', 'trim|required|callback_athlete_not_exist');
$this->form_validation->set_rules('athEmail', 'email', 'trim|valid_email');
$this->form_validation->set_rules('gender', 'type', 'trim|required');
//|callback_athlete_not_exist
if($this->form_validation->run())
{
// Validation passes
$athId = $this->athlete_model->AddAthlete($_POST);
if($athId)
{
$this->session->set_flashdata('flashConfirm', 'The athlete has been successfully added.');
redirect('athletes');
}
else
{
$this->session->set_flashdata('flashError', 'A database error has occured, please contact your administrator.');
redirect('athletes');
}
}
$data['main_content'] = 'athletes/athletes_add_form';
$this->load->view('includes/template', $data);
//$this->load->view('users/users_add_form');
}
Model content is below. I tried adding the info in red below but that's not working. Since date doesn't come from the form how do I get it inserted with the below insert?
Quote: function AddAthlete($options = array('date' => 'date("Y")'))
{
// required values
if(!$this->_required(
array('firstname',
'lastname',
'gender',
'name'
),
$options)
) return false;
$options = $this->_default(array('athStatus' => 'active'), $options); //declares all users active by default
$this->db->insert('athlete', $options);
$last_id = $this->db->insert_id();
$athId = $last_id;
return $athId;
}
Thanks for any help.