Generate input fields for custom types in connected forms
Environment information
carl@Carls-MacBook-Pro ~/Devel/.../website (rel_20241010) npx ampx info
System:
OS: macOS 14.6.1
CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 1.10 GB / 32.00 GB
Shell: /bin/zsh
Binaries:
Node: 22.4.1 - /usr/local/bin/node
Yarn: undefined - undefined
npm: 10.8.1 - /usr/local/bin/npm
pnpm: undefined - undefined
NPM Packages:
@aws-amplify/auth-construct: 1.4.0
@aws-amplify/backend: 1.6.0
@aws-amplify/backend-auth: 1.3.0
@aws-amplify/backend-cli: 1.4.0
@aws-amplify/backend-data: 1.1.6
@aws-amplify/backend-deployer: 1.1.6
@aws-amplify/backend-function: 1.7.3
@aws-amplify/backend-output-schemas: 1.4.0
@aws-amplify/backend-output-storage: 1.1.3
@aws-amplify/backend-secret: 1.1.4
@aws-amplify/backend-storage: 1.2.2
@aws-amplify/cli-core: 1.2.0
@aws-amplify/client-config: 1.5.1
@aws-amplify/deployed-backend-client: 1.4.2
@aws-amplify/form-generator: 1.0.3
@aws-amplify/model-generator: 1.0.8
@aws-amplify/platform-core: 1.1.0
@aws-amplify/plugin-types: 1.3.1
@aws-amplify/sandbox: 1.2.4
@aws-amplify/schema-generator: 1.2.5
aws-amplify: 6.6.0
aws-cdk: 2.165.0
aws-cdk-lib: 2.165.0
typescript: 5.5.4
AWS environment variables:
AWS_STS_REGIONAL_ENDPOINTS = regional
AWS_NODEJS_CONNECTION_REUSE_ENABLED = 1
AWS_SDK_LOAD_CONFIG = 1
No CDK environment variables
Describe the feature
When generating connected forms using npx ampx generate forms, the resulting forms should include elements for custom types.
Use case
One of my models has a few custom types, for example:
// Installation table
Installation: a
.model({
...
// The location of the installation
location: a.customType({
lat: a.float(),
lon: a.float(),
}),
// Fields required for Victron integration
victronConfiguration: a.customType({
installationId: a.string(),
portalId: a.string(),
}),
// Solar PV plane configuration
planes: a.ref('Plane').array(),
...
// Solar plane definition
Plane: a.customType({
name: a.string(),
azimuth: a.integer().required(),
declination: a.integer().required(),
kwp: a.float().required()
}),
The connected forms generation is really helpful, except that it does not include form elements for custom types like the ones shown above. It would be really useful if it did. For arrays, what would be particularly handy is the ability to also add/remove elements from the array (see the "planes" element above).
Hey,👋 thanks for raising this! I'm going to transfer this over to our codegen repository for better assistance 🙂
Hi @chultquist 👋 thanks for raising this issue. I think I was able to reproduce the behavior you described.
Here are my repro steps:
- I deployed the
Installationmodel andPlanecustomType from your example schema.
const schema = a.schema({
Installation: a
.model({
location: a.customType({
lat: a.float(),
lon: a.float(),
}),
victronConfiguration: a.customType({
installationId: a.string(),
portalId: a.string(),
}),
planes: a.hasMany("Plane", "installationId"),
})
.authorization((allow) => [allow.guest()]),
Plane: a.model({
name: a.string(),
azimuth: a.integer().required(),
declination: a.integer().required(),
kwp: a.float().required(),
}),
});
- Ran the Amplify CLI command
npx ampx generate forms - Rendered the
InstallationCreateFormandInstallationUpdateFormcomponents. - Observed that neither UI components rendered elements, or inputs, for the
PlanecustomType.
Because there are no other fields in the Installation model, the form renders without any elements except buttons to clear, reset, or submit.
However, I'm not certain whether this is unexpected behavior or not. I will reach out to the team to find out and label this issue either as a bug or feature request accordingly once I found out.
Thanks, @chrisbonifacio!
We're categorizing this as a bug because we expect this behavior to work per some of our internal testing.
We encountered this issue too. Could you give us an estimate when this bug will be fixed, please?