Forms are wrapped in the FormContainer
component, which styles form elements within.
import live-web.dom
import live-web-view.form
import live-web-view.content
static any[] use = [FormContainer]
FormContainer{
FormGroup{
Label{ htmlFor: 'name' T`Name` }
TextInput{ type='text' placeholder="Name" name="name" }
}
FormGroup{
Label{ htmlFor: 'email' T`Email` }
TextInput{ type='email' placeholder='Email Address' name='email' }
}
FormGroup{
SubmitButton{ T`Submit` }
}
}
import live-web.dom
import live-web-view.form
import live-web-view.content
static any[] use = [FormContainer]
FormContainer{
FormGroup{ layout: FormGroup.Layout.Row
Label{ htmlFor: 'email' T`Email` }
TextInput{ type='email' placeholder='Email Address' name='email' }
}
FormGroup{ layout: FormGroup.Layout.Row
Label{ htmlFor: 'password' T`Password` }
TextInput{ type='password' placeholder='Password' name='password' }
}
}
import live-web.dom
import live-web-view.form
import live-web-view.content
static any[] use = [FormContainer]
FormContainer{
FormGroup{
TextInput{ type='email' placeholder='Email Address' name='email' }
}
FormMessage{ visible: true type: 'error'
T`Error: Email address is invalid.`
}
FormGroup{
TextInput{ type='password' placeholder='Password' name='password' }
}
FormMessage{ visible: true type: 'info'
T`Info: Password should be at least 10 characters.`
}
FormGroup{
SubmitButton{ T`Submit` }
}
}
import live-web.dom
import live-web-view.form
static any[] use = [FormContainer]
FormContainer{
FormGroup{
TextInput{ type='text' placeholder="Text Input" name="input" }
}
}
import live-web.dom
import live-web-view.form
static any[] use = [FormContainer]
FormContainer{
FormGroup{
TextArea{ placeholder="Text Area" name="input" }
}
}
import live-web.dom
import live-web-view.form
static any[] use = [FormContainer]
FormContainer{
FormGroup{ layout: FormGroup.Layout.Row
Label{ htmlFor: 'checkbox' T`Check Box` }
Checkbox{ name='checkbox' }
}
}
import live-web.dom
import live-web-view.form
static any[] use = [FormContainer]
FormContainer{
FormGroup{ layout: FormGroup.Layout.Row
Label{ htmlFor: 'checkbox' T`Check Box` }
Checkbox{ name='checkbox' }
}
}
import live-web.dom
import live-web-view.form
static any[] use = [FormContainer]
FormContainer{
SelectInput{
placeholder='Select ...'
name='select'
options = [
{ value: 'chocolate', label: 'Chocolate' },
{ value: 'vanilla', label: 'Vanilla' },
{ value: 'strawberry', label: 'Strawberry' }
]
}
}
The SelectExtendedInput
component is a wrapper around choices.js. The options
property allows you to send configuration options to the choices internal object.
import live-web.dom
import live-web-view.form
static any[] use = [FormContainer, DateTimeInput]
FormContainer{
FormGroup{
SelectExtendedInput{
options = ({
choices: [
{
value: 'Option 1',
label: 'Option 1',
selected: true,
disabled: false,
},
{
value: 'Option 2',
label: 'Option 2 [Disabled]',
selected: false,
disabled: true
},
{
label: 'Group 1',
choices: [
{
value: 'Option 3',
label: 'Option 3',
selected: true,
disabled: false,
},
{
value: 'Option 4',
label: 'Option 4',
selected: false,
disabled: false
}
]
}
]
})
}
}
}
import live-web.dom
import live-web-view.form
static any[] use = [FormContainer, PasswordInput]
FormContainer{
FormContainer{
FormGroup{
PasswordInput{
placeholder='Password ...'
name='password'
}
}
}
}
The DateTimeInput
component is a wrapper around flatpickr. The options
property allows you to send configuration options to flatpickr.
import live-web.dom
import live-web-view.form
static any[] use = [FormContainer, DateTimeInput]
FormContainer{
FormContainer{
FormGroup{
DateTimeInput{
name = 'date'
placeholder = 'Date ...'
}
}
FormGroup{
DateTimeInput{
name = 'time'
placeholder = 'Time ...'
options = ({ noCalendar: true, enableTime: true })
}
}
FormGroup{
DateTimeInput{
name = 'date-time'
placeholder = 'Date and Time ...'
options = ({ enableTime: true })
}
}
FormGroup{
DateTimeInput{
name = 'date-range'
placeholder = 'Date Range ...'
options = ({ mode: 'range' })
}
}
}
}