Form builders help you quickly build up form components.
You can instantiate a FormBuilder
instance and interact with it directly.
use Steams\Ui\Form\FormBuilder;
$builder = new FormBuilder($parameters = []);
Defining forms in your stream configuration makes it easy to display, validate, and customize forms based your domain information and entities.
Define stream forms using a handle => parameters
format, where handle
will be used to reference the form later and parameters
is an array of parameters and components configuration.
// streams/example.json
{
"ui": {
"forms": {
"default": {
"options.redirect": "thank-you"
}
}
}
}
The following parameters are available though may not be required.
Use the stream
parameter to specify the stream to use for entry data. If the form was defined on a stream this is optional.
use Steams\Ui\Form\FormBuilder;
$builder = new FormBuilder([
'stream' => 'contacts',
]);
Use the entry
parameter to specify the entry id
or instance to use for the form. If none is specified, default behavior will create a new entry upon submission.
use Steams\Ui\Form\FormBuilder;
$builder = new FormBuilder([
'stream' => 'contacts',
'entry' => Request::get('id'),
]);
Use the builder
parameter to override the builder instance used to build the form component.
// streams/example.json
{
"ui": {
"forms": {
"default": {
"builder": "App\\MyFormRepository"
}
}
}
}
Use the repository
parameter to override the repository instance used to fetch the entry. This parameter defaults to the stream configured repository if any.
// streams/example.json
{
"ui": {
"forms": {
"default": {
"repository": "App\\MyFormRepository"
}
}
}
}
Options listed here:
Form configurations can also be @imports for more congiguration
{
"ui": {
"form": {}
}
}
Full configuration:
{
"ui": {
"forms": {
"default": {},
"{handle}": {}
}
}
}
$form = (new FormBuilder([
'stream' => 'examples',
'inputs' => [
'field_slug' => 'input_type',
],
]))->build();
Configuration Examples
{
"form": [
// Required Configuration
"stream", // The stream the entry belongs to
"entry", // The entry to edit or null to create
// Optional Configuration
"repository", // The entry repository
"builder", // The form builder to use
"form", // The form component to use
"assets", // Assets to load
"fields", // Form fields configuration
"rules", // Form rules configuration
"actions", // Form actions configuration
"buttons", // Form buttons configuration
"sections", // Form sections configuration
"options": [ // Component options array
""
]
],
}
A blank TALL-stack Laravel project with Streams.
The fundamental features and utilities offered by the Streams platform.
A universal and extensible RESTful API for Streams.
Extensible, user-friendly, and performant control panel, components, and services.
Dev tooling for Laravel Streams.