Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Conversation

@tdurnford
Copy link
Collaborator

@tdurnford tdurnford commented Sep 23, 2020

Description

Adds the ability to add additional fields to the Adaptive Form. To add an additional field, developers only have to add a new property with the additionalField option set to true and a field override to the properties option in the UIOptions. The <ObjectField /> will recognize the new field and add it to the schema.

const uiOptions = {
  order: ['schemaField1', 'schemaField2', '*', 'additionalField']
  properties: {
    additionalField: {
      additionalField: true,
      field: () => <div>Additional Field</div>,
    }
  }
}

Order

Additional fields can be included in the UI Option order override by adding the additional field's name to the order array. Note, the additional field's name can not exist as a property name in the schema.

const uiOptions = {
  order: ['schemaField1', 'schemaField2', '*', 'additionalField']
  properties: {
    additionalField: {
      additionalField: true,
      field: () => <div>Additional Field</div>,
    }
  }
}

Field sets

Additional fields can also be included in field sets by adding the additional field's name to the fields array in the field set.

const uiOptions = {
  fieldset: [{ titile: 'field set 1', fields: ['schema field 1', 'additionalField', '*' }],
  properties: {
    additionalField: {
      additionalField: true,
      field: () => <div>Additional Field</div>,
    }
  }
}

Task Item

Closes #4208

@coveralls
Copy link

coveralls commented Sep 23, 2020

Coverage Status

Coverage increased (+0.05%) to 55.759% when pulling d7b1aca on tdurnford:feature/additional-fields into b0f2fd8 on microsoft:main.

@a-b-r-o-w-n
Copy link
Contributor

This isn't directly related to this PR, but I'm curious how fieldsets and order work together?

Copy link
Contributor

@a-b-r-o-w-n a-b-r-o-w-n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that when processing ui options, we take additionalFields and merge that into the schema and ui options so that

{
  SomeKind: {
    additionalFields: [{ name: 'newField', field: SomeFieldWidget, description: 'some description' }]
  }
}

becomes

// schema
{
  SomeKind: {
    properties: {
      // ... other properties
      newField: { type: 'string' }
    }
  }
}

// ui options
{
  SomeKind: {
    properties: {
      newField: {
        description: 'some description'
      }
    }
  }
}

I'm not sure about modifying the schema, but I think this approach would work nicely with the ui options. What do you think?

@tdurnford
Copy link
Collaborator Author

This isn't directly related to this PR, but I'm curious how fieldsets and order work together?

Currently, the the ui order take priority over the order provided in the fieldset. Not sure if I like that behavior. Thoughts?

@tdurnford tdurnford changed the title feat: Add additional fields to UIOptions feat: Adds support for additional properties in UIOptions Sep 24, 2020
Copy link
Contributor

@a-b-r-o-w-n a-b-r-o-w-n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one suggestion.

@tdurnford tdurnford changed the title feat: Adds support for additional properties in UIOptions feat: Adds support for additional fields in UIOptions Sep 25, 2020
a-b-r-o-w-n
a-b-r-o-w-n previously approved these changes Sep 29, 2020
@a-b-r-o-w-n a-b-r-o-w-n added duplicate This issue or pull request already exists and removed duplicate This issue or pull request already exists labels Sep 29, 2020
@tdurnford tdurnford merged commit 34734fe into microsoft:main Sep 29, 2020
@tdurnford tdurnford deleted the feature/additional-fields branch September 29, 2020 20:14
@cwhitten cwhitten mentioned this pull request Nov 13, 2020
lei9444 pushed a commit to lei9444/BotFramework-Composer-1 that referenced this pull request Jun 15, 2021
* feat: Add additional fields to UIOptions

* update file reference

* lint

* Delete PivotFieldsets.tsx

* removed additionalFields option

* removed additional fields ui option

* added additional field

* updated form row

* lint

* changed properties to union type

* fixed build errors

* resolved test issues

* lint

* removed AdditionalField type

* fix test
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider adding additional fields to ui schema

3 participants