Contact Form
Jump to navigation
Jump to search
Detailed Name
First Name
Herbert
Last Name
Wells
Middle Name
George
Initials
H. G.
Notes
Email Addresses
Phone Numbers
Links
Address
Street
City
State
Postal Code
Country
This page demonstrates a form which proposes a solution for the "name field dilemma", where the user could enter a single well-known name, or by contrast the complete, formal name of a person. In both cases a third hidden entry "fullname" (visible here) is auto-generated either from the single name, or from the compounded name, using a JavaScript template.
This real-life problem is solved thanks to the following technical features:
- Watchers. The fullname field watches either the name field or the compounded name object for changes.
- Conditions. The effective schema is modified based on the user-selection (single name or compounded name). If the single name is selected, the fullname field watches the string field. If the compounded name is selected, the fullname field watches all the compounded name fields (salutation, first_name, middle_name, last_name, suffix), using a template to compose the actual name.
- Templates. A Handlebars-like template is used to compose the effective name, in this form
{{name.salutation}} {{name.first_name}} {{name.middle_name}} {{name.last_name}} {{name.suffix}} - json-schema combination (oneOf). OneOf is used to provide the user with a switch to interactively select a schema (single name or compounded name). Once the data change, the condition schema gets triggered and updates the active schema.
Schemas:
Parser function:
{{#jsonforms:Default
|schema=Contact
|edit={{FULLPAGENAME}}
|width=800px
}}
loading form
See also