Skip to main content

Class: FormBuilder

Layout.FormBuilder

Define a UI Form from a

Stream within a LayoutBuilder.

Remarks

A Form is editable when defined from a writable

Stream, such as produced by a SourceBuilder

Example

  // use a StructType stream
const stream = Stream(
"My Writeable Stream",
StructType({
string: StringType,
date: DateTimeType,
float: FloatType,
min_float: FloatType,
max_float: FloatType,
integer: IntegerType,
boolean: BooleanType,
}),
true
);

// create a form in a layout
const layout = new LayoutBuilder("My Layout")
.form("My Form", builder => builder
.fromStream(stream)
.date("Date", fields => fields.date)
.string("String", fields => fields.string)
.integer("Integer", fields => fields.integer)
.boolean("Boolean", fields => fields.boolean)
.float(
"Float",
{
value: fields => fields.float,
min: fields => fields.min_float,
max: fields => fields.max_float,
}
)
)
.toTemplate()

Layout

constructor

new FormBuilder(name)

Define a UI Form from a

Stream within a LayoutBuilder.

Remarks

A Form is editable when defined from a writable

Stream, such as produced by a SourceBuilder

Example

  // use a StructType stream
const stream = Stream(
"My Writeable Stream",
StructType({
string: StringType,
date: DateTimeType,
float: FloatType,
min_float: FloatType,
max_float: FloatType,
integer: IntegerType,
boolean: BooleanType,
}),
true
);

// create a form in a layout
const layout = new LayoutBuilder("My Layout")
.form("My Form", builder => builder
.fromStream(stream)
.date("Date", fields => fields.date)
.string("String", fields => fields.string)
.integer("Integer", fields => fields.integer)
.boolean("Boolean", fields => fields.boolean)
.float(
"Float",
{
value: fields => fields.float,
min: fields => fields.min_float,
max: fields => fields.max_float,
}
)
)
.toTemplate()

Parameters

NameType
namestring

fromStream

fromStream<T>(stream):

FormFinalizer<T, {}>

Define the

Stream to build a FormBuilder within a LayoutBuilder.

Example

  // use a StructType stream
const stream = Stream(
"My Writeable Stream",
StructType({
string: StringType,
date: DateTimeType,
float: FloatType,
min_float: FloatType,
max_float: FloatType,
integer: IntegerType,
boolean: BooleanType,
}),
true
);

// create a form in a layout
const layout = new LayoutBuilder("My Layout")
.form("My Form", builder => builder
.fromStream(stream)
.inputs()
)
.toTemplate()

Type parameters

NameType
Textends StructType<Record<string, EastType>>

Parameters

NameTypeDescription
streamStream<T>the StructType Stream to build the table from

Returns

FormFinalizer<T, {}>