I have a field in my table which does not need any validation rule. It’s an optional field so I didn’t added a validation to it but when I hit submit - with value in that field - is not saved. If I add a validation to the field, required for ex, the content is saved into the database. Any idea why Yii performs this way?
major method:
you can add the safe rule in your model~ even if without the field actually~
other method:
you can use $post->save(false) to skip the validate of model~
public function rules() {
return array(
array('Street, Number, ZipCode, Phone, Fax', 'safe')
);
}
Yes. As to why Yii behaves like this, that’s explained here.