mirror of
https://github.com/dzeiocom/FormManager.git
synced 2025-04-22 10:52:16 +00:00
3.1 KiB
3.1 KiB
Form Manager
A powerfull Manager for all your forms
Table of Content
Installation
nothing difficult
yarn add @dzeio/form-manager
or
npm install @dzeio/form-manager
usage
Typescript
import FormManager from '@dzeio/form-manager';
const fm = new FormManager(docuement.getElementById("form"));
// add modules
import { FMRepeatAssignment } from '@dzeio/FormManager/modules/FMRepeatInput'
fm.assign(FMRepeatAssignment)
// or
import FMDateInput from '../FormManagerGit/modules/FMDateInput'
fm.assign({
input: FMDateInput,
type: "date",
tagName: "input"
});
// After adding modules run to reffect modules to inputs
fm.setupInputs();
// verify form validity:
fm.verify(); //return true if valid else return false
// if it returns false you can use the variable under to see th FMInput that isnt valid
fm.lastErroredInput
// submit your data to an endpoint
fm.submit("/api/idk", (ev) => {/* onloaded callback*/}, /* verify datas beforehand default:true*/ true)
// get the json of your form
fm.getJSON()
// fill form from URI (datas MUST be in JSON (see getJSON for examples))
fm.fillFromURI("uri")
// same as before but you give the json from ts
fm.fillFromJSON(json)
// change if you only see the form or edit them
fm.setMode(FMMode.ViewMode or FMMode.EditMode)
// same thing as before but just for one field
fm.setModeForInput(FMMode.ViewMode or FMMode.EditMode, "inputName")
// Reset the form to it's defaults values
fm.clear()
Modules & Attributes
Modules
Module name | Description |
---|---|
Datalist | Manage the datalist better than ever ! |
Date | Manage the date element |
File | Manage single file uploads |
Repeat | Make your fields repeatable ! |
Select | Fix your Select |
Attributes
Attribute name | Description |
---|---|
data-autoset | Update your value in near realtime |
data-default | a better value than value |
data-ignore | i don't see this |
data-regex | regex your value |
Issues
Complete listing here