Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Ask HN: Is there a markup language for forms?
33 points by benkarst on Jan 5, 2020 | hide | past | favorite | 11 comments
I've been coding web and mobile apps for 12 years and I've worked on countless forms. It seems like there should exist a formal way to define them (field names, data types, validation, endpoints, etc.), compatible with backend and frontend languages. Then a library, in each given language to render the form. Anyway, I'd like to define a form once and render it or process it without any extra work. Do any hackers know of such a thing?


I've seen several decent implementations based on https://json-schema.org/implementations.html#web-ui-generati...

Json schema also has many tools for validation, which is nice if you're passing the form data around.


JSONForm (https://github.com/jsonform/jsonform) looks very promising. Thanks!



There's this for Vue: https://github.com/vue-generators/vue-form-generator

Looks promising. However my recommendation is create single components for common elements you use a lot...

Like... have a structure like resources/js/form/elements where you might have: Input.vue Email.vue Password.vue and all types... set some sensible defaults put use props so they're all overrideable.

Then create forms by model: resources/js/users/forms: FirstName.vue would look something like: <template><form-input extraJson:"{readonly: true}" /></template>

Then your users/form.vue would be like" <template> <first-name /> <last-name> <email> </template>

Then say you have two types of users like users and customers... and two different forms -- you can reuse the email/name input modules in other forms so you don't duplicate content. I use inertiajs+laravel+vue though, and handle validations via laravel and don't generally need to use the whole json schema thing, as it just makes for more code. I like handling the validations in the backend and let the frontend just focus on ui/ux.


I ended up creating my own, in yaml, with rails backend.

Includes multiple nested field sets, fields shown/activated by other fields etc.

The gist is: structure in yaml/json, then field code templates in partials, and validations on the back end. Included Salesforce list validations which was pretty neat.

The code is nowhere near reusable unfortunately.


This might not be exactly what you’re looking for — it’s meant more for interactive editorial features than simple forms — but Idyll looks really cool and is worth a look.

https://idyll-lang.org/



Just be aware, XForms is a fairly niche standard. I worked with XForms a bit in 2004 and had high hopes for it, but it never reached a critical mass in terms of adoption.

https://stackoverflow.com/questions/40325231/is-xforms-still...

Like most XML standards, it favors generality over simplicity. There are some indications that while this is good for complicated forms, it could be overkill for simple forms.

https://lists.w3.org/Archives/Public/public-forms/2014Oct/00...


I once started inventing such a thing called FORMCARD, which supports paper forms as well as computer, and also includes transport protocol to submit the forms, as well as the file format to describe the form, but not much has been done with that since then.


Use html5 and make code snippets in editor. So when typing form it will create form with all input elements and you del not needed.


Dream Features - one to many




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: