Hiding form fields

I’m sure Yii has a really great, easy way to do this, but I haven’t been able to find it:

I have a modified column on my table, but I don’t want it to show on the form when I edit that model. What’s the best way to hide it? I don’t need the value to be set, the database is already handling that.

Thanks in advance.

How about to not render that form field at all?

Sorry if I didn’t understand your question…

also, make sure you remove references to that field in the model rules

Yes, not rendering that form field is what I would like to do. What’s the best way to do that? Is there a setting that tells it to hide it?

delete the corresponding code in the view file

I was thinking that, but I was wondering if there was a ‘better’ way, like some setting in the rules or something like that.


You can conditionally display fields based on the scenario of the model. If what you’re trying to do is have the field hidden but only in certain cases. Just use an if, there’s no need to make it fancy.