Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate input fields for custom types in connected forms #14059

Open
chultquist opened this issue Dec 12, 2024 · 3 comments
Open

Generate input fields for custom types in connected forms #14059

chultquist opened this issue Dec 12, 2024 · 3 comments
Labels
pending-triage Issue is pending triage transferred This issue was transferred from another Amplify project

Comments

@chultquist
Copy link

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).

@chultquist chultquist added the pending-triage Issue is pending triage label Dec 12, 2024
@ykethan
Copy link
Member

ykethan commented Dec 12, 2024

Hey,👋 thanks for raising this! I'm going to transfer this over to our codegen repository for better assistance 🙂

@ykethan ykethan transferred this issue from aws-amplify/amplify-backend Dec 12, 2024
@ykethan ykethan added the transferred This issue was transferred from another Amplify project label Dec 12, 2024
@phani-srikar phani-srikar transferred this issue from aws-amplify/amplify-codegen Jan 7, 2025
@chrisbonifacio
Copy link
Member

chrisbonifacio commented Jan 8, 2025

Hi @chultquist 👋 thanks for raising this issue. I think I was able to reproduce the behavior you described.

Here are my repro steps:

  1. I deployed the Installation model and Plane customType 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(),
  }),
});
  1. Ran the Amplify CLI command npx ampx generate forms
  2. Rendered the InstallationCreateForm and InstallationUpdateForm components.
  3. Observed that neither UI components rendered elements, or inputs, for the Plane customType.

Because there are no other fields in the Installation model, the form renders without any elements except buttons to clear, reset, or submit.

CleanShot 2025-01-08 at 12 25 38@2x

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.

@chultquist
Copy link
Author

Thanks, @chrisbonifacio!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending-triage Issue is pending triage transferred This issue was transferred from another Amplify project
Projects
None yet
Development

No branches or pull requests

3 participants