TP5 How to display different fields on an interface

Source: Internet
Author: User
This article mainly introduces about TP5 how to display different fields on the interface, has a certain reference value, now share to everyone, the need for friends can refer to

Environmental ThinkPHP5 PHP7.0.10

We usually hide some fields and apply them to different interfaces.

Change the database's configuration file first, changing the data set return type to collection

The query for our interface below is handled either by find () or select ()

$Group = $Group->hidden ([' name ']);

$Group is the data that mode queries, and this line of code means to hide the name.

Of course we can also use the visible () method to define what fields are displayed, so that in the model I can add some fields that do not need to be displayed in the $hidden array, and the selection of the other fields in the controller

Let's look at an example

This is all the information read

Below we hide the name field

Or just display the name

In this way, we can flexibly define the interface display information to the client, in the model can also not choose to hide, the client's information display is selected in the controller

Suppose I hide this field in the model, and then select Show only This field in the controller, he will also be displayed on the client side.

You can see that the model is hidden and can be changed by the controller.

Related recommendations:

PHP5 Connecting an image field in a mssql2005 database table display

Related Article

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.