Module: ezform

Methods

(inner) expandShorthand(field) → {Object}

Expand field definition from shorthand: simple string, or array
Parameters:
Name Type Description
field string | array | Object shorthand field definition
Source:
Returns:
field definition as an argument for Field()
Type
Object

(inner) Field(f) → {Object}

High level user input field inc optional label, multiple options etc
Parameters:
Name Type Description
f Object field proerties
Properties
Name Type Attributes Default Description
ezTitle string <optional>
meaningful title for field
label string <optional>
f.ezTitle label element
placeholder string <optional>
f.ezTitle placeholder property
name string <optional>
name property - defaults to ezTitle or placeholder snake-cased
prefix string <optional>
"" id prefix (eg. for use if >=2 forms on page)
id string <optional>
f.prefix + f.name id for input/textarea; number will be suffixed for options' ids
type string <optional>
html input type or "textarea"
options Array.<Object> <optional>
array of options' attributes for checkbox, radio and select
...props Object <optional>
other dom/vdom/react attributes
Source:
Returns:
vnode with optional label
Type
Object
Examples
Field({placeholder: "email"})
Field({placeholder: "email", style:{color: red}})
<Field placeholder="email"></Field>

(inner) Form(f) → {Object}

Creates form element
Parameters:
Name Type Description
f Object Form properties
Properties
Name Type Attributes Description
onSubmit function <optional>
callback will receive object containing values entered after submit suppressed
children function <optional>
child elements (as in React for example)
...props function <optional>
form properties/attributes
Source:
Returns:
vnode
Type
Object
Example
<Form onSubmit={({email}) => console.log({email})}>
       <Field placeholder="email"> </Field>
    <Form>

(inner) parseFormInputs(elements) → {Object}

Parse form values, eg for onSubmit. Exposed for testing purposes.
Parameters:
Name Type Description
elements Object event.target
Source:
Returns:
event target values in a convenient form
Type
Object
Example
example return value:

{
 "inputs": {
  "text_input_with_value": "quick brown fox",
  "textarea": "quick brown fox jumped.\nYes he did.\n",
  "checkboxes": [
    "Apple"
  ],
  "radios": "Pear",
  "select_fruit": [
    "apple",
    "Pear"
  ]
 }
}