FormItem::{type}('{field name}', '{label}')

Creates new form element and adds it to the current model configuration.

Supported Types

Validation

FormItem::text('title')->required()->unique()->validationRule('my-custom-rule')

See details about validation.

Custom HTML attributes

You can add custom html attributes to the form element.

FormItem::text('title')->attributes(['class' => 'my-class', 'my-attribute' => 1])

Default Value

You can set default value for form element.

FormItem::text('title')->default('My new item title')

Register Custom Type

See custom form elements.