Learn how to setup main Photon CMS field parameters.Table of Contents
- Field Type
- Field Name
- Column Name
- Relation Name
- Related Module
- Tooltip Text
- Validation Rules
- Default Value
- Field Group
- Is System
- Is Default Search Choice
- Pivot Table Name
- Local Key
- Foreign Key
- Lazy Loading
- Can Create Search Choice
- Flatten To Optgroups
- Is Active Entry Filter
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 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 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.
Required: Yes (for Relation Field Types)
Relation Name represents the name of a relation in snake_case notation.
Required: Yes (for Relation Field Types)
Related Module represents the module a field should form relation with.
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 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.
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.
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:
- The generator needs to be in the module editing mode (you can't select a field group in module creation mode)
- The field group needs to be pre-created and assigned to the edited module (each module needs to have it's own field groups)
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.
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).
Setting the Hidden option to true (On) will hide the field in the module form.
Setting the Is System parameter to true (On) would make the field readable and settable to the system, only.
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.
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.
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.
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.
Custom local key in snake_case notation that will be used for relation. If the value is not provided, it will be auto-generated.
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.
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.
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.
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:
Name of the field from a related module that is used for filtering search choices inside the select menus.