Drag and Drop Form Builder #639
Replies: 21 comments 34 replies
-
This is super cool @jarredwitt, nice work 💯 I think a lot of people would benefit from seeing what the source code looks like if you ever have time to share (either specific or general approach). |
Beta Was this translation helpful? Give feedback.
-
That looks really nice. How are you handling the 'cloning' of the draggable? I'm currently at a road block trying to use a dragoverlay. |
Beta Was this translation helpful? Give feedback.
-
Hi @jarredwitt any progress on this? I need something like this, so maybe i could help you. :-) |
Beta Was this translation helpful? Give feedback.
-
Hi @jarredwitt I am confused with the 'cloning' and I am a junior developer, do you have time to make a small example in the code sandbox? Thank you very much!!! |
Beta Was this translation helpful? Give feedback.
-
Hi all, I’ll start working on a code sandbox example this week(not able to share the actual code from the example above) and post it here when finished. It’ll be simplified, but I’ll make sure that it demonstrates how I’m handling the cloning from the sidebar to the canvas. |
Beta Was this translation helpful? Give feedback.
-
Hi All, Here's a link to the sandbox example. https://codesandbox.io/s/dnd-kit-form-builder-fii0zh It's not prod ready at all, but it at least shows the process that was used in the screen grab above. Be happy to answer any questions. Also more than willing to hear feedback on design approach as well. |
Beta Was this translation helpful? Give feedback.
-
That's really nice, gj @jarredwitt! Have you thought of adding a 2 column layout for some form elements as well? |
Beta Was this translation helpful? Give feedback.
-
Great work!!, are you willing to share the source code :) ?! |
Beta Was this translation helpful? Give feedback.
-
Hello Jarred, great work! |
Beta Was this translation helpful? Give feedback.
-
Hi Jarred, There is a little bug in your sandbox example. When you drag a sidebar field to the canvas from the top, the spacer appears at the bottom. When you drop it, it drops from the top, which is expected, but do you have any idea why the spacer appears at the bottom? |
Beta Was this translation helpful? Give feedback.
-
Hi Jarred, This is great work- thanks so much for sharing with the community. I love dnd-kit, but it's a vast library with (unfortunately) not so easy to follow documentation. Your example is helping me with my own project, where I have a similar (but not exactly the same) setup. Similarities:
Differences:
I got pretty far with my own initial attempts to build my setup, and got stuck on making the sorting "auto-animate" when new items are being dragged into the drop zone. Now that I see your code, I can tell I was doing some things that may be fundamentally wrong. Your App.js core architecture (and subsequent children) has a different structure than mine, and I think I need to re-factor mine to work similarly. You have the Sortable Context in App.js, I had mine in a child component (my drop zone). I think the real difference, however, is the two modes you have for Drag Overlay. I only have one... I do not have a clear understanding of Drag Overlay, and how it works with useSortable / Sortable Context. I know it doesn't make much sense to anyone stumbling on this comment at this time. I need to provide some code to reference here. I'll be working on a scaled down version of your approach that I will eventually build back up for production. I will post some results here, and probably add it to a new discussion. In the meantime I just wanted to say thanks, and that your source code has given me hope! |
Beta Was this translation helpful? Give feedback.
-
Hi Jarred, how you learn to work with dndkit their doc is bad |
Beta Was this translation helpful? Give feedback.
-
Great example thank you. However I have a question. Why in the example, in Canvas.js we can do this for the useDroppable hook but in Typescript, I get
|
Beta Was this translation helpful? Give feedback.
-
Hi, this is great job here ! |
Beta Was this translation helpful? Give feedback.
-
What kind of database do you use to achive the store of the new information form? it needs to be a non-relational?....thanks you! |
Beta Was this translation helpful? Give feedback.
-
Hi @jarredwitt, great stuff! I am currently working on implementing a grid layout system that allows users to have draggable components within multiple columns to your current sandbox example. Essentially, users should be able to drag and drop a grid layout container and have the flexibility to edit the number of columns that container has. Additionally, they should be able to drag other fields into that container. I would greatly appreciate it if you could provide me with guidance or point me in the right direction to achieve this functionality.
If you could possibly provide code examples, it would be incredibly helpful. |
Beta Was this translation helpful? Give feedback.
-
Hi all, due to the amount of interest this discussion has generated I've been toying with the idea of creating some content that shows how to build something similar to the form builder that was first posted to this discussion. I want to divide the content up into two courses that would build on each other. The first course would show how to build out the basic form builder along with the elements sidebar, simple properties panel, styling and preview capability. It would basically take the codesandbox example posted above and extend it to look more like the posted video grab that started this discussion. The end result of the course would be a basic form builder that you can extend. This course will be free and posted to youtube as playlist series. The second course would build on top of the first and would show off the following:
The end result of the second course would be a full featured form builder that's capable of creating forms, capturing form submissions and viewing those submissions. Planning on using NextJS, TS, MUI and SQLite. This would be a much larger undertaking than the first course so I'm planning on making this course available for a one time fee. I haven't decided what that fee will be or where it will be hosted, but I'll be sure to update this discussion with future details. In the meantime so I can gauge interest, add a 👍 to this post if you think something like the above sounds beneficial. More than happy to hear any feedback as well. |
Beta Was this translation helpful? Give feedback.
-
Hey @jarredwitt. There's a bug where if one of the elements are larger (like text in your example) and you try and put it between smaller items (like two buttons). The detection does not work properly and its finicky to get the large item placed in between the two. Using collisionDetection={closestCenter} in DndContext mostly fixes the issue but causes another issue (Items from the sidebar will automatically go straight into the canvas. I was wondering if there was a solution to fix this? |
Beta Was this translation helpful? Give feedback.
-
I need a Two Column Row field that is draggable and droppable. a row which has two columns in it and each column should act as drop targets. how to achieve it using react js functional component |
Beta Was this translation helpful? Give feedback.
-
Hello first of all thanks jarred for the code. I managed to refactor it a bit to make my own. For now I have the dnd and the sorting. export function Field(props) {
const { field, overlay, ...rest } = props;
const { type } = field;
const Component = getRenderer(type);
console.log({ Component });
return (
<Box
sx={{ width: "100%" opacity: overlay ? 0.5 : 1 }}
>
<Component {...rest} />
</Box>
);
} |
Beta Was this translation helpful? Give feedback.
-
Hi Jarred Witt, can you please give the exact code for dnd form builder. Because i want integrate the exact form builder like this |
Beta Was this translation helpful? Give feedback.
-
Hi all,
Been using dnd-kit for some time now and love it. Wanted to show off the form builder that I've been working on. Would be happy to answer any questions and also very accepting of any feedback 😀.
Screen.Recording.2022-03-01.at.1.18.52.PM.mov
Beta Was this translation helpful? Give feedback.
All reactions