PHP Development Framework Yii Framework Tutorial (a) Zii component-detailview sample

Source: Internet
Author: User

Cdetailview displays details for a model. The model to be displayed can be either a cmodel or an associative array.

Cdetailview configure attributes to determine which properties of the model need to display in what format.

Each property can be configured using Name:Type:Label. Where type and label are optional.

Name of the "name" property.

"Label" Optionally, the label name of the property, if not configured, using the property name as the label name.

The type of the "type" property, which determines the format to display by type formatter. The types you can use are raw, text, ntext, HTML, date, Time, DateTime, Boolean, number, email, image, Url. , and so on, the text is used by default.

This example modifies the previous example of the Yii Framework Development Tutorial (a) Zii component-listview example, modifies the list item template _view.php of the display list to make the customer name from plain text into link.

 

When you click on the customer's name, go to the link view.php, the incoming parameter CustomerID set to the customer ID.
Creating view.php, using Cdetailview components

 

Use the default format to display each of the customer's fields, the main Employee field, table customer defined is supportrepid as foreign key reference employee, so modify the class customer definition relations, reference yii Framework Development Tutorial (27) database-associated Active record example

Public Function relations ()     
{return     
    array (     
        ' Employee ' =>array (self::belongs_to, '     
        employee ', ' Supportrepid '),     
        );     
}

The results appear as follows:

This example downloads: Http://www.imobilebbs.com/download/yii/DetailViewDemo.zip

See a full set of tutorials: http://www.bianceng.cn/webkf/PHP/201301/35265.htm

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.