Rules:
Array ('new field', 'safe ', 'on' => 'search ')
1. array ('new field', 'safe ') // If You Want To input this field, add it,
2. array ('new field', 'Numerical '), // if it is a number
3. array ('new field', 'length', 'Max' => 100), // if it is text
1, 2, 3 add at least one appropriate field to save the new field.
AttributeLabels:
'New field' => 'new field', // about the displayed label
Search:
$ Criteria-> compare ('new field', $ this-> new field, true); // The gridview is searched here.
Example of adding a gridview:
Array ('name' => 'new field', 'filter' => $ array/*, 'type' => 'Raw' // it seems that this is not required for the new YII version, as long as the filter is an array */),
From above: http://jiangzhixiang123.blog.163.com/blog/static/278020622011111263110296/
In addition, the view modification method:
View. php:
$ This-> widget ('zii. widgets. cdetailview', array (
'Data' => $ model,
'Bubuckets' => array (
'Id ',
'New field ',
)
LIST _ view. php:
<B> <? Php echo CHtml: encode ($ data-> getAttributeLabel ('new field');?> : </B>
<? Php echo CHtml: encode ($ data-> new field);?>
<Br/>
Form _ form. php:
<Div class = "row">
<? Php echo $ form-> labelEx ($ model, 'new field');?>
<? Php echo $ form-> textField ($ model, 'new field', array ('SIZE' => 60, 'maxlength' => 255);?>
<? Php echo $ form-> error ($ model, 'new field');?>
</Div>
Search _ search. php:
<Div class = "row">
<? Php echo $ form-> label ($ model, 'new field');?>
<? Php echo $ form-> textField ($ model, 'new field', array ('SIZE' => 60, 'maxlength' => 255);?>
</Div>
OK. Is everything going well ?!
When this function is used again today
When a field is added, the attribute "Blog. name" is not defined.