Skip to Content
FrontendCrud V2Crud GeneratorGenerator v2Custom Properties

Custom Properties

The StorageBundle/CustomProperty entity has special generator handling: two fields (tableName, fieldType/propertyType) are rendered as finite SELECT dropdowns backed by static config files instead of free-text inputs.

For the frontend component that renders custom property fields on entity forms, see the Custom Properties component in the CRUD bundle.


How It Works

1. Static Config Files

Two config files provide the dropdown options:

FileExportPurpose
config/tableNames.jsTableNamesAll entity table names (generated by gen:table-names)
config/propertyTypes.jsPropertyTypesSupported field types (manually maintained)

2. Generator Detection

In template-generator.js, AddImportStatements() detects when the entity is StorageBundle/CustomProperty and injects:

import { TableNames } from "../tableNames"; import { PropertyTypes } from "../propertyTypes";

The customPropertiesCustomFieldsGen() function then generates SELECT fields for tableName, fieldType, and propertyType instead of the default TEXT type.

3. changes.json fieldOverrides

You can also trigger this via fieldOverrides in changes.json for any entity that needs finite dropdowns:

"fieldOverrides": { "tableName": { "optionsArrayFinite": "TableNames" }, "fieldType": { "optionsArrayFinite": "PropertyTypes" }, "propertyType": { "optionsArrayFinite": "PropertyTypes" } }

When optionsArrayFinite is set on a field, template-generator.js emits ColumnTypeEnum.SELECT with the raw identifier as optionsArrayFinite.


Generated Output

The generated index.tsx for StorageBundle/CustomProperty includes:

import { TableNames } from "../tableNames"; import { PropertyTypes } from "../propertyTypes"; // In formInputs: { title: "Table Name", key: "tableName", type: ColumnTypeEnum.SELECT, optionsArrayFinite: TableNames, placeholder: "Select tableName", required: true, }, { title: "Field Type", key: "fieldType", type: ColumnTypeEnum.SELECT, optionsArrayFinite: PropertyTypes, placeholder: "Input fieldType", required: true, }, { title: "Property Type", key: "propertyType", type: ColumnTypeEnum.SELECT, optionsArrayFinite: PropertyTypes, placeholder: "Input propertyType", required: true, },

Setup Steps

Generate Table Names

Run after generating all your entities to populate the TableNames list:

./index.js gen:table-names

Verify config/propertyTypes.js

This file is static — update the values list if your backend adds new property types.

Regenerate Custom Properties TSX

./index.js gen:tsx \ --entity=StorageBundle/CustomProperty \ --bundleCrud=phprCrud

Export to Frontend Project

./index.js exportEntity \ --entity=StorageBundle/CustomProperty \ --destination=../my-frontend/src/crud_config/

The frontend project must have config/tableNames.js and config/propertyTypes.js accessible at ../tableNames and ../propertyTypes relative to the entity’s index.tsx. Copy both files into the project’s config folder when exporting.

Last updated on