简体   繁体   English

CakePHP智能列名称

[英]CakePHP Smart Column names

When creating tables for a CakePHP 2.X application there are certain column names that Cake will automatically process in special ways. 在为CakePHP 2.X应用程序创建表时,Cake将使用某些特殊方式自动处理某些列名称。 The most obvious I can think of would be "created" and "modified" (which Cake will automatically handle when rows are created or edited). 我能想到的最明显的是“创建”和“修改”(在创建或编辑行时Cake将自动处理)。 There's "name" which will by default be used as a model's display name. 默认情况下,将使用“名称”作为模型的显示名称。 To a lesser degree "email" and "phone" automatically select their appropriate validation rules when Baking the project. 烘焙项目时,“电子邮件”和“电话”会在较小程度上自动选择其适当的验证规则。

My Question is: Does anyone have a comprehensive list of these column names? 我的问题是: 有人有这些列名的完整列表吗?

I've tried looking through the CakePHP site and Google searches, but either this list does not exist, or I'm using the wrong the terms. 我尝试浏览CakePHP网站和Google搜索,但是该列表不存在,或者我使用的术语错误。

Thank you. 谢谢。

For the forms, if the field name is: 对于表单,如果字段名称为:

'pasword', 'passwd', 'password' => it will be displayed as password fields 'pasword', 'passwd', 'password' =>它将显示为密码字段

'tel', 'telephone', 'phone' => it will be displayed a type = "tel" 'tel', 'telephone', 'phone' =>它将显示为类型=“ tel”

'text' => textarea 'text' =>文本区域

'time' => time drop-downs 'time' =>时间下拉菜单

'datetime', 'timestamp' => date + time drop-downs 'datetime', 'timestamp' =>日期+时间下拉菜单

'date' => date drop-downs 'date' =>日期下拉菜单

'created', 'updated', 'modified' are automatically filled when using model->save() 使用model-> save()时,将自动填充'created', 'updated', 'modified'

You also mentioned "name" which is a model attribute. 您还提到了"name" ,这是一个模型属性。 The list of attributes is here 属性列表在这里

You can see more about how the fields are displayed in forms in the FormHelper.php and more about how the model works in Model.php from Cake core 您可以在CakeHelp的FormHelper.php中看到有关字段如何显示形式的更多信息,以及有关Model.php中模型如何工作的更多信息。

Regarding cake bake validations: 关于蛋糕烘烤验证:

if field name is email, it will be validated as email. 如果字段名称是电子邮件,它将被验证为电子邮件。 The other validations are based on field type: 其他验证基于字段类型:

  • type string => validation: notEmpty 类型字符串=>验证:notEmpty
  • type integer => validation: numeric 输入整数=>验证:数字
  • type float => validation: numeric 输入float =>验证:数字
  • type boolean => validation: boolean 类型boolean =>验证:boolean
  • type date => validation: date 输入日期=>验证:日期
  • type time => validation: time 输入时间=>验证:时间
  • type datetime => validation: datetime 输入datetime =>验证:datetime
  • type inet => validation: ip 输入inet =>验证:ip

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM