1.0.6 • Published 4 months ago
@mpndev/form-builder v1.0.6
Form Builder
Installation:
npm install @mpndev/form-builder
Example: build form with 3 text inputs. one of them is normal text input, the other two will be text input and password input, wrapped together in a wrapper div element. Lets put and one submit button in the end.
const formBuilder = require('form-builder')
const express = require("express")
const app = express()
app.listen(3000, () => {
console.log("Application started and Listening on port 3000");
});
app.get("/", (req, res) => {
const label = formBuilder.createLabel({
title: 'first input',
defaultValue: 'first input',
})
const label2 = formBuilder.createLabel({
defaultValue: 'second input',
title: 'second input'
})
const inputTypeText = formBuilder.createTextInput({label: label})
const inputTypePassword = formBuilder.createPasswordInput({label: label2})
const inputTypeText2 = formBuilder.createTextInput()
const wrapper = formBuilder.createWrapper({elements: [inputTypeText, inputTypePassword]})
const submitButton = formBuilder.createSubmit()
const form = formBuilder.createForm({
elements: [
wrapper,
inputTypeText2
],
submit: submitButton
})
res.send(`<html><head></head><body>${form.build()}</body></html>`)
});