When i update using the form below, it wont change the date of birth… i all of a sudden stopped working…
//usersController
public function actionUpdate($id)
{
$model=$this->loadModel($id);
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Users']))
{
$model->attributes=$_POST['Users'];
$model->LastUpdate=date_create()->format('Y-m-d H:i:s');
if($model->save()) {
$auth=Yii::app()->authManager;
$auth->revoke(Roles::model()->findByPk(Users::model()->findByPk($model->id)->roles_id)->description,$model->id);
$auth->assign(Roles::model()->findByPk($model->roles_id)->description,$model->id);
$this->redirect(array('viewProfile','id'=>$model->id));
}
}
$this->render('update',array(
'model'=>$model,
));
}
//Model Rules
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('username, password, callsign, rank, joindate, DOB, gender, picture, fetishes, orientation, email, muted, DateCreated, LastUpdate, roles_id, positions_id', 'required'),
array('rank, gender, muted, roles_id, positions_id', 'numerical', 'integerOnly'=>true),
array('username, password, picture, fetishes, orientation, triggers, hypnotic_nuances, otherim', 'length', 'max'=>255),
array('callsign', 'length', 'max'=>2),
array('email, skype, aim, msn, yim', 'length', 'max'=>45),
array('description', 'safe'),
// The following rule is used by search().
// @todo Please remove those attributes that should not be searched.
array('id, username, password, callsign, rank, joindate, DOB, gender, description, picture, fetishes, orientation, triggers, hypnotic_nuances, email, skype, aim, msn, yim, otherim, muted, DateCreated, LastUpdate, roles_id, positions_id', 'safe', 'on'=>'search'),
);
}
//Form Entry
<div class="row">
<?php echo $form->labelEx($model,'DOB'); ?>
<?php $this->widget('zii.widgets.jui.CJuiDatePicker',array(
'name'=>'Modelname[DOB]',
'id'=>'Modelname_DOB',
'value'=>Yii::app()->dateFormatter->format("y-M-d",strtotime($model->DOB)),
'options'=>array(
'showAnim'=>'slideDown',
'changeMonth'=>true,
'changeYear'=>true,
'dateFormat'=>'yy-mm-dd',
'maxDate' => date('Y-m-d',strtotime('-18 years')),
),
'htmlOptions'=>array(
'style'=>'height:20px;'
),
)); ?>
<?php echo $form->error($model,'DOB'); ?>
</div>
i’ve checked the database… i’ve checked the Rules and have tried adding it into the rules in multiple places. it was working a while ago… and it gives no errors that the update to the database has failed…
just to be clear, DOB is stored as a DATE. and it was working with this form datepicker earlier. i’ve changed nothing in the form or the controller…
here’s the database.
Table structure for table `users`
--
CREATE TABLE IF NOT EXISTS `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL,
`callsign` varchar(2) NOT NULL,
`rank` int(11) NOT NULL,
`joindate` date NOT NULL,
`DOB` date NOT NULL,
`gender` int(11) NOT NULL,
`description` text,
`picture` varchar(255) NOT NULL,
`fetishes` varchar(255) NOT NULL,
`orientation` varchar(255) NOT NULL,
`triggers` varchar(255) DEFAULT NULL,
`hypnotic_nuances` varchar(255) DEFAULT NULL,
`email` varchar(45) NOT NULL,
`skype` varchar(45) DEFAULT NULL,
`aim` varchar(45) DEFAULT NULL,
`msn` varchar(45) DEFAULT NULL,
`yim` varchar(45) DEFAULT NULL,
`otherim` varchar(255) DEFAULT NULL,
`muted` tinyint(1) NOT NULL,
`DateCreated` datetime NOT NULL,
`LastUpdate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`roles_id` int(11) NOT NULL,
`positions_id` int(11) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `username_UNIQUE` (`username`),
UNIQUE KEY `callsign_UNIQUE` (`callsign`),
KEY `fk_users_roles_idx` (`roles_id`),
KEY `fk_users_positions1_idx` (`positions_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ;