Ignore Column On Create And Update

I’m just starting out with YII, and have created the first application to get to learn the way it works. Now I run into this small issue. I’ve created a database in Postgres, with create_date and update_date fields. I’ve set the default value for both these fields to now(). For the update_date I’ve created a trigger that updates the field on each change of the record.

For both fields, the database handles everything that is needed. The update and create forms can forget about these two fields. I know YII could insert the current datetime, but that’s not what I want. The form should not insert an empty field or a null value either. I do want to show both fields on the view page however, so you can see when an item is created or updated.

I would think that this can be handled in the model, in a rule. But I have no clue how, and it probably involves some extra function elsewhere…

Any help is appreciated!

To quote the rules() method of a model generated by Gii:

public function rules()


	// NOTE: you should only define rules for those attributes that

	// will receive user inputs.

	return array(

If you want any user input for those fields to be ignored, remove them from all rules (except the one used by search() if you want them to be searchable). Then remove the inputs from your form and you’re done.

Thanks! I got it working! :)