![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Informal is a form-building library. It takes a JavaScript object which specify how the form should look and then takes it from there. Using a JavaScript object as the source of the form means you can store it in a JSON file and write a server-side validation script for it, meaning you can keep things in one location.
Informal is written in CommonJS format and can be installed through npm
. Using
this, you can use a tool such as [browserify][browserify] to add it to your
build.
$ npm install --save informal
Once installed, you can use Informal as follows:
var informal = require('informal');
var form = new informal.Form(spec, data);
myElement.appendChild(form.wrap);
Where spec
is your form definition , and data
is an object with values for
your fields.
Forms created by Informal always consist of at least one page
, group
and
field
. Even if you require only a single page or group, this hierarchy is
still expected. A sample form definition would look something like this:
{
"pages": [
{
"name": "Personal details",
"groups": ["group1"]
}
],
"groups": {
"group1": {
"name": "Your name",
"fields": ["first_name", "last_name"]
}
},
"fields": {
"first_name": {
"type": "text",
"label": "First name"
},
"last_name": {
"type": "text",
"label": "Last name"
}
}
}
The hierarchy, as you can see, is always pages
> groups
> fields
. The
reason they're not actually nested is cause this way it'll be easier to also use
for validation, for example.
The main definition can contain the following keys
pager
: pager optionspages
: array of page objectsgroup
: object of groupsfields
: object of fieldsAll are required, except pager
.
pager
The pager object has two possible keys
type
: pager type, defaults to numbered
position
: where to put the pager, can be top
or bottom
pages
Each item in the array is a page: an object with the following keys
type
: page type, defaults to default
name
: page namegroups
: array of group namesgroups
The keys in this object are referenced by the groups
property of each page.
Each group can contain the following keys
type
: group type, defaults to default
name
: group namefields
: array of field namesfields
The keys in this object are referenced by the fields
property of each group.
Each key is also used as the name
if it isn't specified. The following keys
are generic for each field type
type
: field typelabel
: label textname
: name of the fieldvalue
: default valuerequired
: true if field is requiredattributes
: object with key/value pairs for html attributestext
/email
/password
/number
/date
/time
{
"type": "text",
"label": "First name"
}
type
: one of text
, email
, password
, number
, date
or time
single_option
{
"type": "single_option",
"style": "radio",
"label": "Gender",
"options": [
{ "value": "male", "label": "Male" },
{ "value": "female", "label": "Female" }
]
}
style
: rendering style, select box (select
, default) or radio buttons
(radio
)options
: an array of objects
value
: actual value of the optionlabel
: display value of the option, defaults to value
multi_option
{
"type": "multi_option",
"style": "checkbox",
"label": "Interests",
"options": [
{ "value": "cycling", "text": "Cycling" },
{ "value": "gaming", "text": "Gaming" },
{ "value": "skateboarding", "text": "Skateboarding" },
{ "value": "swimming", "text": "Swimming" }
],
"value": ["cycling", "skateboarding"]
}
style
: rendering style, select box (select
, default) or checkboxes
(checkbox
)options
: an array of objects
value
: actual value of the optionlabel
: display value of the option, defaults to value
value
: can also be an array for this field type, if multiple options are
selectedFAQs
Forms made simple
We found that informal demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.