YiiFramework development tutorial (31) Zii component-DetailView example

Source: Internet
Author: User
YiiFramework development 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.

Double-click all code
12 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

Double-click all code
12345678910111213141516171819202122232425 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, which is the main Employee field. the Customer table defines SupportRepId as the foreign key reference. Therefore, the Customer-like definition Relations is modified, see Yii Framework Development Tutorial (27) database-associated Active Record example

Double-click all code
1234567 Publicfunctionrelations () {returnarray ('employee' => array (self: BELONGS_TO, 'employee', 'orortrepid '),);}

The result is as follows:

Download this example

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.