Field Options


Learn how to setup main Photon CMS field parameters.

Table of Contents
  1. Field Type
  2. Field Name
  3. Column Name
  4. Relation Name
  5. Related Module
  6. Tooltip Text
  7. Validation Rules
  8. Default Value
  9. Field Group
  10. Editable
  11. Disabled
  12. Hidden
  13. Is System
  14. Nullable
  15. Indexed
  16. Is Default Search Choice
  17. Pivot Table Name
  18. Local Key
  19. Foreign Key
  20. Lazy Loading
  21. Can Create Search Choice
  22. Flatten To Optgroups
  23. Is Active Entry Filter

Field Type

Each available field type is described in detail in it's own section. Use the Resources navigation to learn about available Photon CMS field types.

Field Name

Required: Yes

Field Name is a human-readable field name. 

When you start typing in the Field Name field, a Column Name string will be auto-generated. Once you modify the Column Name manually, the auto-generation script stops allowing you to keep a custom-set Column Name.

Column Name

Required: Yes

Column Name represents a column name in a snake_case notation. 

When you start typing in the Field Name field, a Column Name string will be auto-generated. Once you modify the column name manually, the auto-generation script stops allowing you to keep a custom-set column name.

Relation Name

Required: Yes (for Relation Field Types)

Relation Name represents the name of a relation in snake_case notation.

Related Module

Required: Yes (for Relation Field Types)

Related Module represents the module a field should form relation with.

Tooltip Text

Required: No

Represents a text which will be used in Photon CMS Control Panel to implement a popup over a field with a custom field explanation.

Validation Rules

Required: No

Validation rules should be written using Laravel validation notation, and these rules will be applied when creating or updating a module entry.

For example, setting a rule to required|unique:users|max:255 will mean the following:

  • A field value needs to be set (required)
  • A field value must be unique in the users table (unique:users)
  • A field value string length shouldn't be more than 255 characters (max:255)

Learn more how you can leverage Laravel validation in the official Laravel validation documentation.

Default Value

Required: No

A default value is the value that should be initially applied when rendering a new module entry form.

E.g. if you chose to create a Boolean field, and you set the default value to '1', that means that the Boolean switch will initially be set to the 'On' position. Setting the default value to '0' would set the switch to the 'Off' position.

A word of caution: 

Be careful when setting the default value to match the chosen field type, as this could break your database structure leading to some migration issues. E.g. if you chose the Boolean field type, and set the default value to 'On' instead of '1', that will create problems.

Field Group

If you wish to add a field to a certain field group this is where you make the selection. To be able to select a field group certain criteria needs to be fulfilled:

  1. The generator needs to be in the module editing mode (you can't select a field group in module creation mode)
  2. The field group needs to be pre-created and assigned to the edited module (each module needs to have it's own field groups)

Editable

Required: No

Setting the Editable parameter to false (off) would mean that you are free to enter the value for this field when creating an entry, but you will be prevented from editing it afterwards.

Disabled

Requied: No

Setting the Disabled field option to true (On) will show the field in module form it's disabled state, but will prevent you from editing it's value.

This is usable for values that are modified from the outside of Control Panel, but you still want to display the value to a user (e.g. count of user profile pageviews).

Hidden

Required: No

Setting the Hidden option to true (On) will hide the field in the module form.

Is System

Required: No

Setting the Is System parameter to true (On) would make the field readable and settable to the system, only.

Nullable

Required: No

Setting the Nullable parameter to true (On) will make the field nullable in the database.

If you plan to have a field that doesn't need to be populated (field is optional, not required), it's probably a good idea to make it nullable.

Indexed

Required: No

Setting the Indexed parameter to true (On) will make the column indexable. 

This is helpful if you perform search queries on your module often using this specific column. Most of the times this improves the database search performance.

Is Default Search Choice

Required: No

Setting the Is Default Search Choice parameter to true (On) will aid the creation of new module entry from within the remote dropdown. This will "tell" the dropdown which field should accept the value when remotely creating a new entry.

For example, this functionality is helpful if you're using a "Tags" module to tag a number of "Article" module entries.

Pivot Table Name

Required: No

Name of the pivot table in snake_case notation, if the field represents a many-to-many relation. 

If the value is not provided, it will be auto-generated.

Local Key

Required: No

Custom local key in snake_case notation that will be used for relation. If the value is not provided, it will be auto-generated.

Foreign Key

Required: No

Custom foreign key in snake_case notation that will be used for relation. If the value is not provided, it will be auto-generated. 

In case of One-to-many field a user must provide custom foreign key in order for relation within module to be properly generated.

Lazy Loading

Required: No

Setting the Lazy Loading parameter to true (On) will lazy load the data inside the select menus, instead of trying to load all related module entries up-front.

Use this option if related module has many entries to avoid sluggish form loading.

Can Create Search Choice

Required: No

Setting the Can Create Search Choice parameter parameter to true (On) will allow you to create a new entry in remote module "through" the select field.

The field is used in conjunction with the Is Default Search Choice field parameter.

Flatten To Optgroups

Required: No

Setting the Flatten To Optgroups to true (On) would create optgroups from a first level of categorized entries.

This should be used in relations with a 2-level multilevel sortable modules.

Perhaps the video best describes the achieved functionality:

Is Active Entry Filter

Required: No

Name of the field from a related module that is used for filtering search choices inside the select menus.

Sign-up to stay informed about news and updates.