Here's the code i want to work with
<?php echo $form->textField($model,'email_time_created',array('readonly'=>true)); ?>
i want to automatically add the current time to my database
Here's the code i want to work with
<?php echo $form->textField($model,'email_time_created',array('readonly'=>true)); ?>
i want to automatically add the current time to my database
I recommend it to add it at the database, asuming you're using MySQL you can create a trigger before saving and doing something like this:
SET NEW.email_time_created=NOW()
If not, you can do it at Yii/PHP level by adding the following function at the model class:
public function beforeSave(){
$this->email_time_created = CDbExpression('NOW()'); //Only in MYSQL
return parent::beforeSave();
}
It will set the column to the current value before saving the model. Notice that it won't be shown at the form, but you can add it by JS or using php's date() at the form's view.