Friday, December 21, 2012

How to override default database value in form field?


Creation of form in Yii is very easy. You can create it very easily. But sometime it will be headache for you if you are unknown with some features.

Ex : Suppose you have some default value for some column in a table. And you want to create a Create form. Some time it is good to display default values but not always. So, this default value can irritate you.

How to remove default value???

Simple, go to the model class corresponding to your form and add

public $columnNameOne = null;
public $columnNameTwo = null;

Note : You have to include these lines on class level not method level.

Now the above columns will not show default values in form.

No comments:

Post a Comment