class Form implements Renderable

Class Form.

Traits

Constants

REMOVE_FLAG_NAME

Remove flag in has many form.

Properties

protected array $hooks

Supported hooks: submitted, editing, saving, saved, deleting, deleted.

from  HasHooks
static array $availableFields

Available fields.

static array $fieldAlias

Form field alias.

static protected $initCallbacks

Initialization closure array.

array $rows

Field rows in form.

protected Model $model

Eloquent model of the form.

protected Validator $validator
protected Builder $builder
protected array $updates

Data for save to current model from input.

protected array $relations

Data for save to model's relations from input.

protected array $inputs

Input data.

protected Layout $layout
protected array $ignored

Ignored saving fields.

protected Tab $tab
protected bool $isSoftDeletes

Methods

$this
editing(Closure $callback)

Set after getting editing model callback.

from  HasHooks
$this
submitted(Closure $callback)

Set submitted callback.

from  HasHooks
$this
saving(Closure $callback)

Set saving callback.

from  HasHooks
$this
saved(Closure $callback)

Set saved callback.

from  HasHooks
$this
deleting(Closure $callback)

No description

from  HasHooks
$this
deleted(Closure $callback)

No description

from  HasHooks
$this
registerHook(string $name, Closure $callback)

Register a hook.

from  HasHooks
callHooks(string $name, array $parameters = [])

Call hooks by giving name.

from  HasHooks
mixed
callEditing()

Call editing callbacks.

from  HasHooks
mixed
callSubmitted()

Call submitted callback.

from  HasHooks
mixed
callSaving()

Call saving callback.

from  HasHooks
mixed|null
callSaved()

Callback after saving a Model.

from  HasHooks
mixed
callDeleting(mixed $id)

Call hooks when deleting.

from  HasHooks
mixed
callDeleted()

No description

from  HasHooks
__construct($model, Closure $callback = null)

Create a new form instance.

$this
pushField(Field $field)

No description

Model
model()

No description

builder()

No description

$this
edit($id)

Generate a edit form.

$this
tab(string $title, Closure $content, $active = false)

Use tab to split form.

Tab
getTab()

Get Tab instance.

mixed
destroy($id)

Destroy data entity and remove files.

RedirectResponse|Redirector|JsonResponse
store()

Store a new record.

bool|ResponseFactory|JsonResponse|RedirectResponse|Response|mixed|null|Response
update(int $id, null $data = null)

Handle update.

$this
ignore(string|array $fields)

Ignore fields to save.

MessageBag|bool
validationMessages(array $input)

Get validation messages.

array
getRelations()

Get all relations of model from callable.

$this
setAction(string $action)

Set action for form.

$this
setWidth(int $fieldWidth = 8, int $labelWidth = 2)

Set field and label width in current form.

$this
setView(string $view)

Set view for form.

$this
setTitle(string $title = '')

Set title for form.

$this
row(Closure $callback)

Add a row in form.

tools(Closure $callback)

Tools setting for form.

header(Closure $callback = null)

No description

bool
isCreating()

Indicates if current form page is creating.

bool
isEditing()

Indicates if current form page is editing.

$this
disableViewCheck(bool $disable = true)

Disable View Checkbox on footer.

$this
disableEditingCheck(bool $disable = true)

Disable Editing Checkbox on footer.

$this
disableCreatingCheck(bool $disable = true)

Disable Creating Checkbox on footer.

footer(Closure $callback = null)

Footer setting for form.

string
resource(int $slice = -2)

Get current resource route url.

string
render()

Render the form contents.

array|mixed
input(string $key, null $value = null)

Get or set input data.

$this
column(int $width, Closure $closure)

Add a new layout column.

array|mixed
__get(string $name)

Getter.

array
__set(string $name, mixed $value)

Setter.

__call(string $method, array $arguments)

Generate a Field object and add to form builder if Field exists.

getLayout()

No description

static 
init(Closure $callback = null)

Initialize with user pre-defined default disables, etc.

static void
extend(string $abstract, string $class)

Register custom field.

static void
alias(string $field, string $alias)

Set form field alias.

static 
forget(array|string $abstract)

Remove registered field.

static bool|mixed
findFieldClass(string $method)

Find field class.

callInitCallbacks()

Call the initialization closure array in sequence.

deleteFiles(Model $model, bool $forceDelete = false)

Remove files in record.

$this|JsonResponse
responseValidationError(MessageBag $message)

No description

bool|JsonResponse
ajaxResponse(string $message)

Get ajax response.

mixed
prepare(array $data = [])

Prepare input data for insert or update.

array
removeIgnoredFields(array $input)

Remove ignored fields from input.

array
getRelationInputs(array $inputs = [])

Get inputs for relations.

RedirectResponse
redirectAfterStore()

Get RedirectResponse after store.

RedirectResponse
redirectAfterUpdate(mixed $key)

Get RedirectResponse after update.

RedirectResponse|Redirector
redirectAfterSaving(string $resourcesPath, string $key)

Get RedirectResponse after data saving.

bool
isEditable(array $input = [])

Check if request is from editable.

array|ResponseFactory|Response|Response
handleColumnUpdates(int $id, array $data)

Handle updates for single column.

array
handleEditable(array $input = [])

Handle editable update.

array
handleFileDelete(array $input = [])

No description

array
handleFileSort(array $input = [])

No description

bool
handleOrderable(int $id, array $input = [])

Handle orderable update.

void
updateRelation(array $relationsData)

Update relation data.

array
prepareUpdate(array $updates, bool $oneToOneRelation = false)

Prepare input data for update.

bool
isInvalidColumn(string|array $columns, bool $containsDot = false)

No description

array
prepareInsert($inserts)

Prepare input data for insert.

bool
isHasOneRelation(array $inserts)

Is input data is has-one relation.

array|mixed
getDataByColumn(array $data, string|array $columns)

No description

mixed
getFieldByColumn($column)

Find field object by column.

void
setFieldOriginalValue()

Set original data for each field.

void
setFieldValue($id)

Set all fields value in form.

MessageBag
mergeValidationMessages(Validator[] $validators)

Merge validation messages from input validators.

initLayout()

Initialize filter layout.

static void
doNotSnakeAttributes(Model $model)

Don't snake case attributes.

captcha(mixed $column, mixed $label)

No description

code(mixed $column, mixed $label)

No description

text(mixed $column, mixed $label)

No description

checkbox(mixed $column, mixed $label)

No description

radio(mixed $column, mixed $label)

No description

select(mixed $column, mixed $label)

No description

multipleSelect(mixed $column, mixed $label)

No description

textarea(mixed $column, mixed $label)

No description

hidden(mixed $column, mixed $label)

No description

Id
id(mixed $column, mixed $label)

No description

Ip
ip(mixed $column, mixed $label)

No description

Url
url(mixed $column, mixed $label)

No description

color(mixed $column, mixed $label)

No description

email(mixed $column, mixed $label)

No description

mobile(mixed $column, mixed $label)

No description

file(mixed $column, mixed $label)

No description

image(mixed $column, mixed $label)

No description

date(mixed $column, mixed $label)

No description

datetime(mixed $column, mixed $label)

No description

time(mixed $column, mixed $label)

No description

year(mixed $column, mixed $label)

No description

month(mixed $column, mixed $label)

No description

dateRange(mixed $start, mixed $end, mixed $label)

No description

DateTimeRange
datetimeRange(mixed $start, mixed $end, mixed $label)

No description

timeRange(mixed $start, mixed $end, mixed $label)

No description

number(mixed $column, mixed $label)

No description

currency(mixed $column, mixed $label)

No description

switch() $$column, $label)

No description

display(mixed $column, mixed $label)

No description

divider(mixed $title)

No description

password(mixed $column, mixed $label)

No description

decimal(mixed $column, mixed $label)

No description

html(mixed $html, mixed $label)

No description

tags(mixed $column, mixed $label)

No description

multipleImage(mixed $column, mixed $label)

No description

timezone(mixed $column, mixed $label)

No description

tableInput(mixed $column, mixed $label)

No description

keyWord(mixed $column, mixed $label)

No description

Details

in HasHooks at line 25
$this editing(Closure $callback)

Set after getting editing model callback.

Parameters

Closure $callback

Return Value

$this

in HasHooks at line 37
$this submitted(Closure $callback)

Set submitted callback.

Parameters

Closure $callback

Return Value

$this

in HasHooks at line 49
$this saving(Closure $callback)

Set saving callback.

Parameters

Closure $callback

Return Value

$this

in HasHooks at line 61
$this saved(Closure $callback)

Set saved callback.

Parameters

Closure $callback

Return Value

$this

in HasHooks at line 71
$this deleting(Closure $callback)

No description

Parameters

Closure $callback

Return Value

$this

in HasHooks at line 81
$this deleted(Closure $callback)

No description

Parameters

Closure $callback

Return Value

$this

in HasHooks at line 94
protected $this registerHook(string $name, Closure $callback)

Register a hook.

Parameters

string $name
Closure $callback

Return Value

$this

in HasHooks at line 107
protected callHooks(string $name, array $parameters = [])

Call hooks by giving name.

Parameters

string $name
array $parameters

in HasHooks at line 129
protected mixed callEditing()

Call editing callbacks.

Return Value

mixed

in HasHooks at line 139
protected mixed callSubmitted()

Call submitted callback.

Return Value

mixed

in HasHooks at line 149
protected mixed callSaving()

Call saving callback.

Return Value

mixed

in HasHooks at line 159
protected mixed|null callSaved()

Callback after saving a Model.

Return Value

mixed|null

in HasHooks at line 171
protected mixed callDeleting(mixed $id)

Call hooks when deleting.

Parameters

mixed $id

Return Value

mixed

in HasHooks at line 179
protected mixed callDeleted()

No description

Return Value

mixed

at line 177
__construct($model, Closure $callback = null)

Create a new form instance.

Parameters

$model
Closure $callback

at line 199
$this pushField(Field $field)

No description

Parameters

Field $field

Return Value

$this

at line 215
Model model()

No description

Return Value

Model

at line 223
Builder builder()

No description

Return Value

Builder

at line 235
$this edit($id)

Generate a edit form.

Parameters

$id

Return Value

$this

at line 253
$this tab(string $title, Closure $content, $active = false)

Use tab to split form.

Parameters

string $title
Closure $content
$active

Return Value

$this

at line 265
Tab getTab()

Get Tab instance.

Return Value

Tab

at line 281
mixed destroy($id)

Destroy data entity and remove files.

Parameters

$id

Return Value

mixed

at line 331
RedirectResponse|Redirector|JsonResponse store()

Store a new record.

Return Value

RedirectResponse|Redirector|JsonResponse

at line 375
bool|ResponseFactory|JsonResponse|RedirectResponse|Response|mixed|null|Response update(int $id, null $data = null)

Handle update.

Parameters

int $id
null $data

Return Value

bool|ResponseFactory|JsonResponse|RedirectResponse|Response|mixed|null|Response

at line 440
$this ignore(string|array $fields)

Ignore fields to save.

Parameters

string|array $fields

Return Value

$this

at line 454
MessageBag|bool validationMessages(array $input)

Get validation messages.

Parameters

array $input

Return Value

MessageBag|bool

at line 479
array getRelations()

Get all relations of model from callable.

Return Value

array

at line 515
$this setAction(string $action)

Set action for form.

Parameters

string $action

Return Value

$this

at line 530
$this setWidth(int $fieldWidth = 8, int $labelWidth = 2)

Set field and label width in current form.

Parameters

int $fieldWidth
int $labelWidth

Return Value

$this

at line 549
$this setView(string $view)

Set view for form.

Parameters

string $view

Return Value

$this

at line 563
$this setTitle(string $title = '')

Set title for form.

Parameters

string $title

Return Value

$this

at line 577
$this row(Closure $callback)

Add a row in form.

Parameters

Closure $callback

Return Value

$this

at line 589
tools(Closure $callback)

Tools setting for form.

Parameters

Closure $callback

at line 599
Tools header(Closure $callback = null)

No description

Parameters

Closure $callback

Return Value

Tools

at line 613
bool isCreating()

Indicates if current form page is creating.

Return Value

bool

at line 623
bool isEditing()

Indicates if current form page is editing.

Return Value

bool

at line 635
$this disableViewCheck(bool $disable = true)

Disable View Checkbox on footer.

Parameters

bool $disable

Return Value

$this

at line 649
$this disableEditingCheck(bool $disable = true)

Disable Editing Checkbox on footer.

Parameters

bool $disable

Return Value

$this

at line 663
$this disableCreatingCheck(bool $disable = true)

Disable Creating Checkbox on footer.

Parameters

bool $disable

Return Value

$this

Footer setting for form.

Parameters

Closure $callback

at line 691
string resource(int $slice = -2)

Get current resource route url.

Parameters

int $slice

Return Value

string

at line 707
string render()

Render the form contents.

Return Value

string

at line 724
array|mixed input(string $key, null $value = null)

Get or set input data.

Parameters

string $key
null $value

Return Value

array|mixed

at line 741
$this column(int $width, Closure $closure)

Add a new layout column.

Parameters

int $width
Closure $closure

Return Value

$this

at line 757
array|mixed __get(string $name)

Getter.

Parameters

string $name

Return Value

array|mixed

at line 770
array __set(string $name, mixed $value)

Setter.

Parameters

string $name
mixed $value

Return Value

array

at line 783
Field __call(string $method, array $arguments)

Generate a Field object and add to form builder if Field exists.

Parameters

string $method
array $arguments

Return Value

Field

at line 801
Layout getLayout()

No description

Return Value

Layout

at line 811
static init(Closure $callback = null)

Initialize with user pre-defined default disables, etc.

Parameters

Closure $callback

at line 824
static void extend(string $abstract, string $class)

Register custom field.

Parameters

string $abstract
string $class

Return Value

void

at line 837
static void alias(string $field, string $alias)

Set form field alias.

Parameters

string $field
string $alias

Return Value

void

at line 847
static forget(array|string $abstract)

Remove registered field.

Parameters

array|string $abstract

at line 859
static bool|mixed findFieldClass(string $method)

Find field class.

Parameters

string $method

Return Value

bool|mixed

at line 884
protected callInitCallbacks()

Call the initialization closure array in sequence.

at line 901
protected deleteFiles(Model $model, bool $forceDelete = false)

Remove files in record.

Parameters

Model $model
bool $forceDelete

at line 924
protected $this|JsonResponse responseValidationError(MessageBag $message)

No description

Parameters

MessageBag $message

Return Value

$this|JsonResponse

at line 944
protected bool|JsonResponse ajaxResponse(string $message)

Get ajax response.

Parameters

string $message

Return Value

bool|JsonResponse

at line 966
protected mixed prepare(array $data = [])

Prepare input data for insert or update.

Parameters

array $data

Return Value

mixed

at line 990
protected array removeIgnoredFields(array $input)

Remove ignored fields from input.

Parameters

array $input

Return Value

array

at line 1004
protected array getRelationInputs(array $inputs = [])

Get inputs for relations.

Parameters

array $inputs

Return Value

array

at line 1028
protected RedirectResponse redirectAfterStore()

Get RedirectResponse after store.

Return Value

RedirectResponse

at line 1044
protected RedirectResponse redirectAfterUpdate(mixed $key)

Get RedirectResponse after update.

Parameters

mixed $key

Return Value

RedirectResponse

at line 1059
protected RedirectResponse|Redirector redirectAfterSaving(string $resourcesPath, string $key)

Get RedirectResponse after data saving.

Parameters

string $resourcesPath
string $key

Return Value

RedirectResponse|Redirector

at line 1086
protected bool isEditable(array $input = [])

Check if request is from editable.

Parameters

array $input

Return Value

bool

at line 1099
protected array|ResponseFactory|Response|Response handleColumnUpdates(int $id, array $data)

Handle updates for single column.

Parameters

int $id
array $data

Return Value

array|ResponseFactory|Response|Response

at line 1124
protected array handleEditable(array $input = [])

Handle editable update.

Parameters

array $input

Return Value

array

at line 1142
protected array handleFileDelete(array $input = [])

No description

Parameters

array $input

Return Value

array

at line 1159
protected array handleFileSort(array $input = [])

No description

Parameters

array $input

Return Value

array

at line 1188
protected bool handleOrderable(int $id, array $input = [])

Handle orderable update.

Parameters

int $id
array $input

Return Value

bool

at line 1210
protected void updateRelation(array $relationsData)

Update relation data.

Parameters

array $relationsData

Return Value

void

at line 1326
protected array prepareUpdate(array $updates, bool $oneToOneRelation = false)

Prepare input data for update.

Parameters

array $updates
bool $oneToOneRelation

If column is one-to-one relation.

Return Value

array

at line 1366
protected bool isInvalidColumn(string|array $columns, bool $containsDot = false)

No description

Parameters

string|array $columns
bool $containsDot

Return Value

bool

at line 1385
protected array prepareInsert($inserts)

Prepare input data for insert.

Parameters

$inserts

Return Value

array

at line 1416
protected bool isHasOneRelation(array $inserts)

Is input data is has-one relation.

Parameters

array $inserts

Return Value

bool

at line 1437
protected array|mixed getDataByColumn(array $data, string|array $columns)

No description

Parameters

array $data
string|array $columns

Return Value

array|mixed

at line 1463
protected mixed getFieldByColumn($column)

Find field object by column.

Parameters

$column

Return Value

mixed

at line 1481
protected void setFieldOriginalValue()

Set original data for each field.

Return Value

void

at line 1499
protected void setFieldValue($id)

Set all fields value in form.

Parameters

$id

Return Value

void

at line 1531
protected MessageBag mergeValidationMessages(Validator[] $validators)

Merge validation messages from input validators.

Parameters

Validator[] $validators

Return Value

MessageBag

at line 1545
protected initLayout()

Initialize filter layout.

at line 1557
static protected void doNotSnakeAttributes(Model $model)

Don't snake case attributes.

Parameters

Model $model

Return Value

void

at line 72
Captcha captcha(mixed $column, mixed $label)

No description

Parameters

mixed $column
mixed $label

Return Value

Captcha

at line 72
Code code(mixed $column, mixed $label)

No description

Parameters

mixed $column
mixed $label

Return Value

Code

at line 72
Text text(mixed $column, mixed $label)

No description

Parameters

mixed $column
mixed $label

Return Value

Text

at line 72
Checkbox checkbox(mixed $column, mixed $label)

No description

Parameters

mixed $column
mixed $label

Return Value

Checkbox

at line 72
Radio radio(mixed $column, mixed $label)

No description

Parameters

mixed $column
mixed $label

Return Value

Radio

at line 72
Select select(mixed $column, mixed $label)

No description

Parameters

mixed $column
mixed $label

Return Value

Select

at line 72
MultipleSelect multipleSelect(mixed $column, mixed $label)

No description

Parameters

mixed $column
mixed $label

Return Value

MultipleSelect

at line 72
Textarea textarea(mixed $column, mixed $label)

No description

Parameters

mixed $column
mixed $label

Return Value

Textarea

at line 72
Hidden hidden(mixed $column, mixed $label)

No description

Parameters

mixed $column
mixed $label

Return Value

Hidden

at line 72
Id id(mixed $column, mixed $label)

No description

Parameters

mixed $column
mixed $label

Return Value

Id

at line 72
Ip ip(mixed $column, mixed $label)

No description

Parameters

mixed $column
mixed $label

Return Value

Ip

at line 72
Url url(mixed $column, mixed $label)

No description

Parameters

mixed $column
mixed $label

Return Value

Url

at line 72
Color color(mixed $column, mixed $label)

No description

Parameters

mixed $column
mixed $label

Return Value

Color

at line 72
Email email(mixed $column, mixed $label)

No description

Parameters

mixed $column
mixed $label

Return Value

Email

at line 72
Mobile mobile(mixed $column, mixed $label)

No description

Parameters

mixed $column
mixed $label

Return Value

Mobile

at line 72
File file(mixed $column, mixed $label)

No description

Parameters

mixed $column
mixed $label

Return Value

File

at line 72
Image image(mixed $column, mixed $label)

No description

Parameters

mixed $column
mixed $label

Return Value

Image

at line 72
Date date(mixed $column, mixed $label)

No description

Parameters

mixed $column
mixed $label

Return Value

Date

at line 72
Datetime datetime(mixed $column, mixed $label)

No description

Parameters

mixed $column
mixed $label

Return Value

Datetime

at line 72
Time time(mixed $column, mixed $label)

No description

Parameters

mixed $column
mixed $label

Return Value

Time

at line 72
Year year(mixed $column, mixed $label)

No description

Parameters

mixed $column
mixed $label

Return Value

Year

at line 72
Month month(mixed $column, mixed $label)

No description

Parameters

mixed $column
mixed $label

Return Value

Month

at line 72
DateRange dateRange(mixed $start, mixed $end, mixed $label)

No description

Parameters

mixed $start
mixed $end
mixed $label

Return Value

DateRange

at line 72
DateTimeRange datetimeRange(mixed $start, mixed $end, mixed $label)

No description

Parameters

mixed $start
mixed $end
mixed $label

Return Value

DateTimeRange

at line 72
TimeRange timeRange(mixed $start, mixed $end, mixed $label)

No description

Parameters

mixed $start
mixed $end
mixed $label

Return Value

TimeRange

at line 72
Number number(mixed $column, mixed $label)

No description

Parameters

mixed $column
mixed $label

Return Value

Number

at line 72
Currency currency(mixed $column, mixed $label)

No description

Parameters

mixed $column
mixed $label

Return Value

Currency

at line 72
SwitchField switch() $$column, $label)

No description

Parameters

) $$column
$label

Return Value

SwitchField

at line 72
Display display(mixed $column, mixed $label)

No description

Parameters

mixed $column
mixed $label

Return Value

Display

at line 72
Divider divider(mixed $title)

No description

Parameters

mixed $title

Return Value

Divider

at line 72
Password password(mixed $column, mixed $label)

No description

Parameters

mixed $column
mixed $label

Return Value

Password

at line 72
Decimal decimal(mixed $column, mixed $label)

No description

Parameters

mixed $column
mixed $label

Return Value

Decimal

at line 72
Html html(mixed $html, mixed $label)

No description

Parameters

mixed $html
mixed $label

Return Value

Html

at line 72
Tags tags(mixed $column, mixed $label)

No description

Parameters

mixed $column
mixed $label

Return Value

Tags

at line 72
MultiImage multipleImage(mixed $column, mixed $label)

No description

Parameters

mixed $column
mixed $label

Return Value

MultiImage

at line 72
Timezone timezone(mixed $column, mixed $label)

No description

Parameters

mixed $column
mixed $label

Return Value

Timezone

at line 72
TableInput tableInput(mixed $column, mixed $label)

No description

Parameters

mixed $column
mixed $label

Return Value

TableInput

at line 72
Keyword keyWord(mixed $column, mixed $label)

No description

Parameters

mixed $column
mixed $label

Return Value

Keyword