diff --git a/FMInput.ts b/FMInput.ts index 8ae2aa6..7e38f01 100644 --- a/FMInput.ts +++ b/FMInput.ts @@ -13,10 +13,23 @@ export default class FMInput { } } + /** + * Set the element Value + * + * @param {*} value + * @memberof FMInput + */ setValue(value: any) { this.element.value = value this.element.setAttribute("value", value) } + + /** + * Get the element value + * + * @returns {*} the value + * @memberof FMInput + */ getValue(): any { return this.element.value } @@ -29,6 +42,12 @@ export default class FMInput { return this.element.getAttribute("name") } + /** + * Verify if the element is correct + * + * @returns {boolean} + * @memberof FMInput + */ verify(): boolean { let val: string = this.getValue() if(val == "" && this.element.hasAttribute("required")) { diff --git a/FormManager.ts b/FormManager.ts index 3172161..e6edab3 100644 --- a/FormManager.ts +++ b/FormManager.ts @@ -1,6 +1,12 @@ import { InputArrayInterface, FMAssignInterface } from './Interfaces'; import FMInput from "./FMInput" +/*! + * FormManager by DZEIO's team + * MIT Licensed + * https://dze.io + */ + /** * * `datalist` upgrade: @@ -16,7 +22,7 @@ import FMInput from "./FMInput" * * * ``` - * **ATTENTION if multiple `option` has the same `value` attribute the `data-value` will be the one of the first one** + * **ATTENTION if multiple `option` have the same `value` attribute the submitted value will be the first one** * * * a `data-ignore` attribute: @@ -60,41 +66,38 @@ import FMInput from "./FMInput" * * * a `repeat` type: - * container: `.form-manager-repeat` - * template (in container): `.form-manager-template` - * add button (in container): `.form-manager-add-button` - * delete button (in template): `.form-manager-delete-button` + * container: `.fm-repeat` with a name attribute + * template (in container): `.fmr-template` + * element (DO NOT PLACE IT YOURSELF) (in container): `.fmr-element` + * add button (in container): `.fmr-add` + * delete button (in template): `.fmr-del` * - * input MUST have data-name and not name attributes - * if the script detect `[x]` it will be replaced by `[${index}]` - * on item deletion all items are re-indexed - * if `data-default` or `data-autoset` contains `{x}` it will be replaced by `${index}` + * input *MUST* have `data-name` and *NOT* `name` attributes + * if `data-default` or `data-autoset` contains `{x}` it will be replaced by the index * - * check if input has attribute `form` and that the value is the current form id - * if so add it to current form * ```html *