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

Feature: Form designer #28

Open
timwis opened this issue Oct 3, 2016 · 1 comment
Open

Feature: Form designer #28

timwis opened this issue Oct 3, 2016 · 1 comment

Comments

@timwis
Copy link
Member

timwis commented Oct 3, 2016

Using this issue to jot down ideas about the form designer. We could try to reuse dobt's form designer ... but if we didn't....

We could use dragula and HTML5's contenteditable, and simply serialize the DOM.

So there'd be a form area, and a way to add fields to it. Adding an <input type="text"> would actually add a <div class="draggable"><label><input><p class="description"></div>. The <div> would have dragula enabled on it. Dragging it around simply rearranges it in the DOM. The <label> and description <p> would have contenteditable="true", letting the user directly edit their contents (which also just updates the DOM).

"Saving" the form would be a matter of exporting formArea.innerHTML. Sure, we could serialize it into JSON if we want to, but there may be an advantage to simply storing the HTML. For instance, you could very easily customize it to infinity. We'd just need a way to associate the fields with the data, but that shouldn't be too hard; just require that each field has a <label> and use an underscorified_version_of_the_label as the field name.

Sounds like fun!

@timwis
Copy link
Member Author

timwis commented Oct 4, 2016

Proof of concept: http://craven-relation.surge.sh/

I don't think this would work as well for <select> boxes ... there'd have to be some kind of configuration panel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant