Merge pull request #11612 from backstage/rugvip/fix
scaffolder: form data fixups
This commit is contained in:
@@ -6,8 +6,8 @@ Get data of other fields in Form from a custom field in template Scaffolder.
|
||||
following:
|
||||
|
||||
```tsx
|
||||
const CustomFieldExtensionComponent(props: FieldExtensionComponentProps<string[]>) => {
|
||||
const { formContext } = props;
|
||||
const CustomFieldExtensionComponent = (props: FieldExtensionComponentProps<string[]>) => {
|
||||
const { formData } = props.formContext;
|
||||
...
|
||||
};
|
||||
|
||||
|
||||
@@ -162,11 +162,15 @@ spec:
|
||||
ui:field: MyCustomExtension
|
||||
```
|
||||
|
||||
## Get data of other fields in Form from a Custom Field Extension
|
||||
## Access Data from other Fields
|
||||
|
||||
Custom fields extensions can read data from other fields in the form via the form context. This
|
||||
is something that we discourage due to the coupling that it creates, but is sometimes still
|
||||
the most sensible solution.
|
||||
|
||||
```tsx
|
||||
const CustomFieldExtensionComponent(props: FieldExtensionComponentProps<string[]>) => {
|
||||
const { formContext } = props;
|
||||
const CustomFieldExtensionComponent = (props: FieldExtensionComponentProps<string[]>) => {
|
||||
const { formData } = props.formContext;
|
||||
...
|
||||
};
|
||||
|
||||
|
||||
@@ -198,7 +198,7 @@ export const MultistepJsonForm = (props: Props) => {
|
||||
widgets={widgets}
|
||||
noHtml5Validate
|
||||
formData={formData}
|
||||
formContext={formData}
|
||||
formContext={{ formData }}
|
||||
onChange={onChange}
|
||||
onSubmit={e => {
|
||||
if (e.errors.length === 0) handleNext();
|
||||
|
||||
Reference in New Issue
Block a user