contactForm question

I am adjusting the standard Yii contactForm and there are some fields that I do not want required. However, when I remove an item from the required array in the the rules() function, the data sent from the form for that particular field is always NULL even if it was filled in.

Does anyone know what might be causing this? I’m sure it’s something simple that I’m overlooking.

Thanks!

You have to have at least one validation rule for it.

An attribute without a validation rule is considered ‘unsafe’ and thus will not be assigned a field value from the form.

http://www.yiiframework.com/doc/guide/1.1/en/form.model#securing-attribute-assignments

That was it. I knew it was something simple I was overlooking.

Thanks!

Or you can just make them safe=)

Yes, that’s what I did.