PHP development framework YiiFramework tutorial (31) Zii component-DetailView example
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,
'Bubuckets' => array (
'Firstname ',
'Lastname ',
'Company ',
'Address ',
'City ',
'State ',
'Country ',
'Postalcode ',
'Phone ',
'Fax ',
'Email ',
Array (
'Name' => 'employe ',
'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', 'supportid '),
);
}
The result is as follows: