简体   繁体   中英

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. The most obvious I can think of would be "created" and "modified" (which Cake will automatically handle when rows are created or edited). 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.

Thank you.

For the forms, if the field name is:

'pasword', 'passwd', 'password' => it will be displayed as password fields

'tel', 'telephone', 'phone' => it will be displayed a type = "tel"

'text' => textarea

'time' => time drop-downs

'datetime', 'timestamp' => date + time drop-downs

'date' => date drop-downs

'created', 'updated', 'modified' are automatically filled when using model->save()

You also mentioned "name" which is a model attribute. 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

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
  • type integer => validation: numeric
  • type float => validation: numeric
  • type boolean => validation: boolean
  • type date => validation: date
  • type time => validation: time
  • type datetime => validation: datetime
  • type inet => validation: ip

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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