I want to have a dropdown for some of objects in the form which are not necessarily shown to the user , so i have written a template called CollapsibleObjectTemplate,
the issue is it is getting applied to every object in the schema
Every object in the schema is now having a dropdown , how to restrict it to only the objects I want ??
example in here every object is getting drop down
import React, { useState } from "react";
const CollapsibleObjectTemplate: React.FC<any> = (props) => {
const [isOpen, setIsOpen] = useState<boolean>(true);
const toggleSection = () => {
setIsOpen(!isOpen);
};
return (
<div style={{ marginBottom: "16px" }}>
<div
onClick={toggleSection}
>
<span>{props.title || "Advanced Settings"}</span>
<span>{isOpen ? "▲" : "▼"}</span>
</div>
{isOpen && (
<div>
{props.properties.map((element: any) => (
<div key={element.name} style={{ marginBottom: "12px" }}>
{element.content}
</div>
))}
</div>
)}
</div>
);
};
export default CollapsibleObjectTemplate;
Form Usage :
<Form
schema={resourceSchema}
uiSchema={uiSchema}
formData={formData}
onChange={({ formData }) => setFormData(formData)}
onSubmit={handleSubmit}
validator={validator}
templates={{ ObjectFieldTemplate : CollapsibleObjectTemplate }}
>
How to use the template on my needs is my using , I think by default every object is getting this
Sai Harsha Gajjavarapu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.