[Scaffolder] Get data of other fields in Form from a custom field
Allows to use e.g.
```
const CustomFieldExtensionComponent(props: FieldExtensionComponentProps<string[]>) => {
const { formContext } = props;
....
};
const CustomFieldExtension = scaffolderPlugin.provide(
createScaffolderFieldExtension({
name: ...,
component: CustomFieldExtensionComponent,
validation: ....
})
);
```
Signed-off-by: Minh Trí <tritri251214@gmail.com>
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
---
|
||||
'@backstage/plugin-scaffolder': minor
|
||||
---
|
||||
|
||||
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 CustomFieldExtension = scaffolderPlugin.provide(
|
||||
createScaffolderFieldExtension({
|
||||
name: ...,
|
||||
component: CustomFieldExtensionComponent,
|
||||
validation: ...
|
||||
})
|
||||
);
|
||||
```
|
||||
@@ -161,3 +161,20 @@ spec:
|
||||
description: My custom name for the component
|
||||
ui:field: MyCustomExtension
|
||||
```
|
||||
|
||||
## Get data of other fields in Form from a Custom Field Extension
|
||||
|
||||
```tsx
|
||||
const CustomFieldExtensionComponent(props: FieldExtensionComponentProps<string[]>) => {
|
||||
const { formContext } = props;
|
||||
...
|
||||
};
|
||||
|
||||
const CustomFieldExtension = scaffolderPlugin.provide(
|
||||
createScaffolderFieldExtension({
|
||||
name: ...,
|
||||
component: CustomFieldExtensionComponent,
|
||||
validation: ...
|
||||
})
|
||||
);
|
||||
```
|
||||
|
||||
@@ -198,6 +198,7 @@ export const MultistepJsonForm = (props: Props) => {
|
||||
widgets={widgets}
|
||||
noHtml5Validate
|
||||
formData={formData}
|
||||
formContext={formData}
|
||||
onChange={onChange}
|
||||
onSubmit={e => {
|
||||
if (e.errors.length === 0) handleNext();
|
||||
|
||||
Reference in New Issue
Block a user