kevinchappell/formBuilder
Über uns
Ein jQuery-Plugin zum Erstellen von Formularen per Drag-and-drop
Weitere ProjekteGemessener Sternzuwachs
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- -1
Nettoänderungen in überlappenden Zeiträumen, keine Tagessummen. Fehlende Messwerte bleiben leer. Sterne zeigen Interesse, nicht Qualität.
README.md
OriginalformBuilder
A jQuery plugin for building forms with drag and drop, plus a companion plugin to render them.
- formBuilder is a client-side drag-and-drop form editor. Users drag fields (text, textarea, select, checkbox and radio groups, date, number, file, autocomplete, button, header, paragraph, hidden and more) onto a stage, then edit each field's label, name, options and other attributes. The form definition is exported as JSON (default) or XML
formData. - formRender takes that
formDataand renders it as a working HTML form. It can also read back what a user entered (userData) or prefill values.
A common setup is formBuilder in an admin area and formRender on the public side.
Demos
- Editor demo
- API demo
- Docs demos: formBuilder basic, formRender basic
Installation
npm / yarn
npm install formBuilder
# or
yarn add formBuilder
The package name is case-sensitive: formBuilder. The built files are in dist/ (form-builder.min.js, form-render.min.js).
CDN (jsDelivr)
<script src="https://cdn.jsdelivr.net/npm/formBuilder@3/dist/form-builder.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/formBuilder@3/dist/form-render.min.js"></script>
formBuilder@3 loads the latest 3.x release. For production, pin an exact version such as [email protected].
Dependencies
- jQuery (
>=3.4.1), required by both plugins. Thedistfiles use the globaljQuery, so load jQuery first. If you use a bundler, exposewindow.jQuerybefore you import formBuilder. - jQuery UI Sortable, required by formBuilder for drag and drop. You can use the
jquery-ui-sortablepackage or a full jQuery UI build.
CSS is injected by the scripts, so you don't need a separate stylesheet.
Quick start
formBuilder
<meta charset="utf-8">
<div id="fb-editor"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.13.2/jquery-ui.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/formBuilder@3/dist/form-builder.min.js"></script>
<script>
jQuery(($) => {
const fbPromise = $('#fb-editor').formBuilder({
disableFields: ['autocomplete'],
onSave: (evt, formData) => console.log(formData),
}).promise
fbPromise.then((formBuilder) => {
const json = formBuilder.actions.getData('json') // 'js' (default), 'json' or 'xml'
console.log(json)
})
})
</script>
formBuilder starts up asynchronously, so actions aren't ready the moment you call .formBuilder(). Wait on the promise property, or call actions later, for example from a click handler.
formRender
<div id="fb-render"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/formBuilder@3/dist/form-render.min.js"></script>
<script>
jQuery(($) => {
const formData = '[{"type":"text","label":"Full Name","name":"full-name","subtype":"text"}]'
const renderer = $('#fb-render').formRender({ formData })
// later, read what the user entered
console.log(renderer.userData)
})
</script>
formData can be a JSON string or the array returned by getData(). To use XML, pass dataType: 'xml'.
Documentation
Full docs: https://formbuilder.online/docs/ · Getting started · formBuilder overview
Common formBuilder options: formData, disableFields, i18n, onSave, typeUserAttrs
Common formBuilder actions: getData, setData, addField, save, setLang
Custom fields: Controls · Control plugins
formRender: Options · userData
Translations (i18n)
Translations are handled by @draggable/i18n. The language files come from formBuilder-languages. en-US is bundled. Other locales are fetched as <location><locale>.lang, and location defaults to the relative path assets/lang/. Set the i18n option to choose a locale and where its file is loaded from:
$('#fb-editor').formBuilder({
i18n: {
locale: 'de-DE',
location: 'https://cdn.jsdelivr.net/npm/[email protected]/',
},
})
Translators welcome!
As more people use formBuilder, it needs to be available in more languages. New languages and fixes to existing ones are always welcome. See Contributing Languages for how to help.
Browser support
The build targets the browserslist defaults query, which covers current versions of the major browsers:
![]() |
![]() |
![]() |
![]() |
![]() |
|---|---|---|---|---|
| Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ |
Internet Explorer is not supported.
Contributing
Contributions are welcome. See CONTRIBUTING.md and the development docs (contributing guide on the site).
git clone https://github.com/kevinchappell/formBuilder.git
cd formBuilder
npm ci
npm start # local demo with Vite (alias: npm run dev)
npm test # Vitest with coverage
npm run lint # ESLint on ./src
npm run build # build dist/ (form-builder + form-render, minified and unminified)
npm run build:all # plugins, vendor, build and copy to the demo
Commit messages follow Conventional Commits and are checked by commitlint. semantic-release uses them to publish releases from master.
Support
Report bugs and request features on GitHub Issues. Include your formBuilder version, the options you used, your browser and steps to reproduce.
Related
- Changelog
- Ng2FormBuilder, a community Angular 2/4 version
License
Ähnliche Projekte entdecken
Wird geladen…





