Mono module that serialize an form object and emits it.
The event module name is configurable (the default value is serializedForm
).
"miidName": {
"module": "github/jillix/form-serializer/MODULE_VERSION"
, "roles": [MONO_ROLES]
, "config": {
"html": "/path/to/html/file.html"
"eventName": "editList"
, "validators": {
"fillForm": "namespace.form_serializer.validateData"
}
, "onFill": {
"binds": [BIND_OBJECTS]
}
, "listen": {EVENT_OBJECTS}
}
, "operations": {
"loadForm": {
"roles": [1]
, "params": [{
"forms": {
"formId1": "/public/html/forms/myForm.html"
}
}]
}
}
}
Function Name | Parameters | Description |
---|---|---|
fillForm (data) |
data : an object, as first function parameter. Use config.onFille.binds to fill the form. |
Fill the form using Bind Mono Module. The binds are configurable from config.onFill.binds . See for more information Bind module. |
showError (err) |
err : a string, as first function parameter. It's the error message that appears in the alert |
Shows an error |
clearErrors () |
No parameters | Clear all errors |
loadForm |
options : object (formId is required), callback : callback function (optional) |
Loads dinamically a form as pointed in [#2](#2) |
Place in the module HTML data-field
and data-value
atributes.
Value | Description | Default value | Required | Example |
---|---|---|---|---|
data-field |
Name of the key from object. |
No default value. | Yes | data-field="author" |
data-value |
It's the name of the function how the value will be taken. | val |
No (will take the default value) | data-value="text" |
data-params |
Params of jQuery function set as data-value . |
No default value | Not required. | data-params="checked" |
data-convert-to |
The data type. Can be one of the following values:
|
No default value | Not required. | data-convert-to="boolean" |
data-delete-if |
If provided, the field will be deleted if it's equal with the attribute value. | No default value | Not required. | data-delete-if="" |
<form>
<input type="text" data-field="author" value="Ionică Bizău" />
<input type="checkbox" data-field="visible" data-value="prop" data-params="checked" value="Ionică Bizău" />
</form>
When the form above will be submitted the following JSON object will be generated and emited:
{
"author": "IonicaBizau"
, "visible": false
}
- transferred the module to the new jxMono organization
- updated Bind to
v0.4.0
, Events tov0.4.0
, Utils tov0.2.0
- Updated to Bind
v0.3.3
, Utilsv0.1.8
and Eventsv0.3.1
- Changed owner to jillix
- Updated to Bind
v0.3.1
- Upgraded deps
- Updated to Events v0.1.11 and Utils v0.1.2
- Removed close button from alert
- Updated to Events v0.1.10
- Bind v0.2.2 and Utils v0.1.1
- added
data-delete-if
attribute feature - deleted deprecated
findValue
andfindFunction
because util library is already imported and contains these methods
- Added Utils in dependencies
- Added LICENSE
- Upgraded Events module
- Added Converters (see
data-convert-to
) - Added dot notation feature
- Override
config.onFill.binds
if a second argument is provided infillForm
function
- Fixed
loadForm
method callback callback
- Added
loadForm
method. See #2 for details.
- Updated to Events v0.1.8 and Bind v0.2.1
- initial release