PHP development framework YiiFramework tutorial (31) Zii component-DetailView example

Source: Internet
Author: User
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 )!

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.