Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QUESTION] Create a custom component #137

Closed
frances-datacom opened this issue Jul 2, 2024 · 3 comments
Closed

[QUESTION] Create a custom component #137

frances-datacom opened this issue Jul 2, 2024 · 3 comments
Assignees
Labels
question Further information is requested

Comments

@frances-datacom
Copy link

Hi,

I'm having trouble figuring out how to create a custom component for the FormBuilder. All the examples I've seen online use JavaScript, but my project uses TypeScript.

I have a codesandbox link that hopefully illustrates the issue: https://codesandbox.io/p/sandbox/sleepy-worker-65cylh

The firstname code comes from this example: https://codesandbox.io/p/sandbox/distracted-butterfly-rzy27w

Any help you can offer would be greatly appreciated!

@frances-datacom frances-datacom added the question Further information is requested label Jul 2, 2024
@Romakita
Copy link
Contributor

Romakita commented Jul 2, 2024

Hi @frances-datacom

I think this issue must be addressed to the formio team. this repo concern @tsed/react-formio which is a fork of the @formio/react package with some additional features (like tailwind themes).

But because I already had this issue, I help you ;)

The main point when you want to enable you custom component in the form builder, is to check if your component name have the same case between the object set to .setComponent and the name given the form builder.

I fixed your issue like that:

const Builder = () => {
  return (
    <div className="App">
      <FormBuilder
        //components={components}
        form={{ display: "form" }}
        options={{
          builder: {
            basic: {
              components: {
                firstName: true, /// case!!!!
              },
            },
          },
        }}
      />
    </div>
  );
};

See you

@Romakita Romakita closed this as completed Jul 2, 2024
Copy link

github-actions bot commented Jul 2, 2024

🎉 Are you happy?

If you appreciated the support, know that it is free and is carried out on personal time ;)

A support, even a little bit makes a difference for me and continues to bring you answers!

github opencollective

@frances-datacom
Copy link
Author

Turns out it was that small, huh? Thank you for your help! I'll see what I can figure out to make the component into Typescript rather than Javascript, and how to get the control to render properly on the FormBuilder. It currently shows this:

image

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants