[eluser]achilez[/eluser]
I have an update validation form, my BirthMonth, BirthDay, and BirthYear content field will get the data from the database. My problem is that there's no action (won't validate/freeze) when i access the accountinfo_form function and reached into "BirthYear" field. Although BirthMonth and BirthDay are working, im just confused is "BirthYear" a reserve/special work or something?
Hope you can help me with this problem, pls see my code below.
Code:
<?
function accountinfo_form() {
$this->load->library('validation');
$this->load->helper('form');
//rules
$rules['firstname'] = "trim|required";
$rules['lastname'] = "trim|required";
$rules['birthmonth'] = "trim|required";
$rules['birthday'] = "trim|required";
$rules['birthyear'] = "trim|required";
$this->validation->set_rules($rules);
//fields
$fields['firstname'] = 'First Name';
$fields['lastname'] = 'Last Name';
$fields['birthmonth'] = 'Month';
$fields['birthday'] = 'Day';
$fields['birthyear'] = 'Year';
$fields['address1'] = 'Address1';
$fields['zipcode'] = 'Zip Code';
$fields['city'] = 'City';
$fields['state'] = 'State';
$fields['country'] = 'Country';
$this->validation->set_fields($fields);
if(isset($_POST['form_trigger'])){
if($this->validation->run() == TRUE){
//update the account information in My Profile
//update the database once the validation is true
$tag['accountinfo_updated'] = '<h3 align="center">Your Account Information was successfully updated!</h3>
<p align="center"><a href="dashboard/index">Back to Dashboard</a></p>';
}
} // end isset
$attributes = array('id' => 'frmaccountinfo');
$tag['begin_form'] = form_open('profile/accountinfo', $attributes);
$sql = "SELECT * FROM tbl_months";
$query = $this->db->query( $sql );
$birthmonthdb[''] = 'Select Month';
foreach( $query->result() as $birthmonth ){
$birthmonthdb[$birthmonth->code] = $birthmonth->name;
}
$tag['birthmonth']= form_dropdown('birthmonth', $birthmonthdb, ($this->validation->run())?$this->validation->birthmonth:$this->common->extractdatemonth("birthdate",0), 'id="birthmonth"');
$tag['birthmonth_error'] = $this->validation->birthmonth_error;
$sql = "SELECT * FROM tbl_days";
$query = $this->db->query( $sql );
$birthdaydb[''] = 'Select Day';
foreach( $query->result() as $birthday ){
$birthdaydb[$birthday->code] = $birthday->name;
}
$tag['birthday']= form_dropdown('birthday', $birthdaydb, ($this->validation->run())?$this->validation->birthday:$this->common->extractdatemonth("birthdate",1), 'id="birthday"');
$tag['birthday_error'] = $this->validation->birthday_error;
$sql = "SELECT * FROM tbl_years";
$query = $this->db->query( $sql );
$birthyeardb[''] = 'Select Year';
foreach( $query->result() as $birthyear ){
$birthyeardb[$birthyear->name] = $birthyear->name;
}
$tag['birthyear']= form_dropdown('birthyear', $birthyeardb, $this->validation->birthyear, 'id="birthyear"');
$tag['birthyear_error'] = $this->validation->birthyear_error;
$tag['submit'] = form_submit('submit', 'Update Profile');
$tag['end_form'] = form_hidden('form_trigger', 'true').form_close();
return $this->parser->parse('accountinfo_form.php', $tag, true);
}
?>