Skip to content
Snippets Groups Projects

implement custom schema field

Merged Philipp S. Sommer requested to merge custom-schema-field into main
2 files
+ 35
1
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -16,6 +16,8 @@ import validator from '@rjsf/validator-ajv8';
import React from 'react';
import { FormEvent } from 'react';
import CustomSchemaField from './SchemaField';
const log = (type: string) => console.log.bind(console, type);
function FunctionForm({
@@ -38,13 +40,20 @@ function FunctionForm({
if (typeof uiSchema === 'undefined') {
uiSchema = {};
}
if (schema.uiSchema) {
uiSchema = { ...uiSchema, ...schema.uiSchema };
}
// @ts-expect-error:next-line
uiSchema.func_name = { 'ui:widget': 'hidden' };
Object.entries(schema.properties).forEach(([prop, attrs]) => {
// @ts-expect-error:next-line
if (attrs.is_reporter) {
// @ts-expect-error:next-line
uiSchema[prop] = { 'ui:widget': 'hidden' };
}
});
return (
<>
<Form
@@ -53,7 +62,7 @@ function FunctionForm({
validator={validator}
onSubmit={typeof onSubmit !== 'undefined' ? onSubmit : log('submitted')}
onError={typeof onError !== 'undefined' ? onError : log('errors')}
fields={fields}
fields={{ SchemaField: CustomSchemaField, ...(fields ? fields : {}) }}
widgets={widgets}
onChange={onChange}
/>
Loading