Form slots


Form attributes related to form slots. Defaults are set in the config file
protected function formAttr(): array
{
return [
'beforeFormView' => 'path/your-blade-view-name', //@include a blade view before the form, above the $headView/$formTitle, $formSubtitle slots
'afterFormView' => 'path/your-blade-view-name', //@include a blade view after the form, below the buttons.
'headView' => 'path/your-blade-view-name', //@include a blade view in the $headView form slot, above the form. Disregards $wrapWithView
'formTitle' => 'string', //displayed above the form if !$headView or !$wrapWithView
'formSubtitle' => 'string', //displayed above the form, below the $formTitle, if !$headView or !$wrapWithView
'footerView' => 'path/your-blade-view-name', //@include a blade view in the $footerView form slot, above the buttons
'formFooterTitle' => 'string', //displayed above the buttons if !$footerView
'formFooterSubtitle' => '', //displayed above the buttons, below the $formFooterTitle, if !$footerView
//See "Layouts vs Wrapper" page
'wrapWithView' => true,
'wrapViewPath' => config('tall-forms.wrap-view-path'),
'layout' => 'layouts.app',
]
}
Tip, custom scripts
$afterFormView
or $beforeFormView
are nice slots to include scripts in combination with some input attributes.
protected function formAttr(): array
{
return [
'afterFormView' => 'scripts/foo';
];
}
// in fields()
Input::make('Name')
->wire('wire:model.defer')
->rootAttr([
'x-data' => "foo()",
'class' => 'border rounded',
])
->inputAttr([
'x-ref' => 'name',
])
->required(),
resources/views/scripts/foo.blade.php
@push('scripts')
<script>
function foo() {
//access this.$refs.name
}
</script>
@endpush
Slot precedence
@if(empty($headView) && !$wrapWithView && ($formTitle || $formSubtitle))
//show formTitle and formSubtitle
@endif
@if(filled($headView))
@include($headView)
@endif
@if(empty($footerView) && ($formFooterTitle || $formFooterSubtitle))
//show formFooterTitle and formFooterSubtitle
@endif
@if(filled($footerView))
@include($footerView)
@end
Styling
Some styles are set in the config file
form-head
form-title
form-sub-title
form-footer
form-footer-title
form-footer-sub-title
Last updated
Was this helpful?