Just a plain ole' text field
new LiveField({
target: model,
attribute: 'name'
})
target |
Viking.Model | Viking.Collection
| |
---|---|---|
attribute |
string
| |
render |
(value, target) => html
| Render value for display |
type |
string
| text, date, duration, select, multi_select |
save |
boolean
| to use .set(attrs) or .save(attrs) . Defaults to typeof target.id !== undefined |
container |
string|Element
| Passed to Uniform.Popover. Determines where Popover is appended. Useful when overflow and positioning issues. |
inputs |
[] | target => Element
| array of objects or a function that returns elements to append. See Multiple Inputs below |
labels |
{}
| Set language used in rendering form |
labels.title |
target => text
| HTML for top of popover |
labels.unset |
string
| HTML used for rendering when value is undefined |
labels.record |
string | record => text
| HTML for labe of each record when split by record. See Collections |
labels.split |
string | record => text
| Text for "Split by ____". See Collections |
Set type to select
and pass options
to generate a dropdown list.
Options can be structured as an array of values, or an array of arrays in the format, [value, text, selected]
, where selected
is a boolean.
new LiveField({
target: model,
attribute: 'status',
type: 'select',
options: ['a', 'b', 'c']
})
By default the value of the passed attribute will be rendered using toString
. Pass render
, a function, to render specific output.
new LiveField({
target: model,
attribute: 'status',
render: (v, target) => `${v} / ${v.toUpperCase()}`
})
Set inputs
to declare what should be rendered in the form. This allows multiple attributes to be manipulated in one form.
new LiveField({
target: model,
attribute: 'rate',
render: (v, target) => `${target.first().get('currency')} ${v}`,
inputs: [
{
type: 'number',
attribute: 'rate'
}, {
type: 'select',
attribute: 'currency'
options: ['USD', 'EUR', 'BTC']
}
]
})