CDetailView displays details for a Model. The Model to be displayed can be a CModel or an associated array. CDetailView configures attributes to determine the format in which the attributes of the Model must be displayed. CDetailView displays details for a Model. The Model to be displayed can be a CModel or an associated array.
CDetailView configures attributes to determine the format in which the attributes of the Model must be displayed.
You can use Name: Type: Label to configure each attribute. Both Type and Label are optional.
"Name" attribute Name.
"Label" can be selected. the Label name of the attribute. if not configured, the attribute name is used as the Label name.
The Type of the "Type" attribute. The formatter format is determined by the Type. available types include raw, text, ntext, html, date, time, datetime, boolean, number, email, image, url.. text is used by default.
In this example, modify the Yii Framework Development Tutorial (30) Zii component-ListView example, and modify the list item template _ view. php of the display list to change the customer name from plain text to Link.
FirstName. ''. $ data-> LastName,
$ This-> createUrl ('View', array ('mermerid' => $ data-> CustomerId);?>
When you click the Customer name, go to the link view. php and set the CustomerId parameter to the Customer ID.
Create View. php and use the CDetailView component.
widget('zii.widgets.CDetailView', array('data'=>$model,'attributes'=>array('FirstName','LastName','Company','Address','City','State','Country','PostalCode','Phone','Fax','Email',array('name'=>'Employee','value'=>$model->employee->FirstName,),),));?>
The default format is used to display each field of the Customer, the main Employee field. the Customer table defines SupportRepId as the foreign key parameter for the Employee test. Therefore, the Customer-like definition Relations is modified, see Yii Framework Development Tutorial (27) database-associated Active Record example
public function relations(){return array('employee'=>array(self::BELONGS_TO,'Employee', 'SupportRepId'),);}
The result is as follows:
The above is the sample content of the Zii component-DetailView in the PHP development Framework Yii Framework tutorial (31). For more information, see The PHP Chinese website (www.php1.cn )!