aws-amplify / amplify-ui

Amplify UI is a collection of accessible, themeable, performant React (and more!) components that can connect directly to the cloud.
https://ui.docs.amplify.aws
Apache License 2.0
920 stars 297 forks source link

ampx generate forms should supported nested "customType" fields #6203

Open nootn opened 5 months ago

nootn commented 5 months ago

Environment information

System:
  OS: Windows 11 10.0.22631
  CPU: (24) x64 AMD Ryzen 9 7845HX with Radeon Graphics
  Memory: 6.25 GB / 31.19 GB
Binaries:
  Node: 20.12.1 - C:\Program Files\nodejs\node.EXE
  Yarn: undefined - undefined
  npm: 10.5.0 - C:\Program Files\nodejs\npm.CMD
  pnpm: undefined - undefined
NPM Packages:
  @aws-amplify/backend: 1.0.0
  @aws-amplify/backend-cli: 1.0.1
  aws-amplify: 6.3.6
  aws-cdk: 2.140.0
  aws-cdk-lib: 2.140.0
  typescript: 5.4.5
AWS environment variables:
  AWS_NODEJS_CONNECTION_REUSE_ENABLED = 1
  AWS_PROFILE = hurtec-dev
  AWS_SDK_LOAD_CONFIG = 1
  AWS_STS_REGIONAL_ENDPOINTS = regional
No CDK environment variables

Description

In a Schema, when you create a customType for nested data, then run npx ampx generate forms, the generated forms will only have input fields for the types on the root level, not the custom type. For example if I have some Device which has gps information, I might structure the data like this:

    Device: a
      .model({
        tenantId: a.string().required(),
        name: a.string().required(),
        status: a.string(),
        gps: a.customType({
          lat: a.float(),
          lon: a.float(),
          spd: a.float(),
          acc: a.float(),
        }),
      })
      .identifier(['tenantId', 'name'])

I will get text boxes for tenantId, name and status, but nothing for the gps data. It can be beneficial to model data like that for other reasons, but at the moment it means you lose the ability to have working forms generated.

As a feature request: I expect it to generate a form with fields for the nested data, possibly in a fieldset or with a heading separating them.

ykethan commented 5 months ago

Hey @nootn, thank you for reaching. Marking this as feature request for customType enhancement on form generation.

bobbyu99 commented 6 days ago

The customType is present in the model introspection schema. So this could be a bug or a feature for UI. @AnilMaktala

image image