Skip to content

Form Slots

tanthammar edited this page Nov 30, 2020 · 11 revisions

All properties on this page are optional.

    public string $beforeFormView;

    public string $headView;
    public string $formTitle;
    public string $formSubtitle;


    public string $footerView;
    public string $formFooterTitle;
    public string $formFooterSubtitle;

    public string $afterFormView;

$beforeFormView

  • $beforeFormView = 'path/your-blade-view-name'
  • @include a blade view before the form, above the $headView/$formTitle, $formSubtitle

$headView or $formTitle and $formSubtitle

HeadView

  • $headView = 'path/your-blade-view-name' @include a blade view in the $headView form slot, above the form. Disregards $wrapWithView.
  • $formTitle, displayed above the form if !$headView or !$wrapWithView
  • $formSubtitle, displayed above the form, below the $formTitle, if !$headView or !$wrapWithView
  • $wrapWithView, see Form Properties page
  • Styling in the config file
    • form-head
    • form-title
    • form-sub-title

form-head.blade.php

@if(empty($headView) && !$wrapWithView && ($formTitle || $formSubtitle))
//show formTitle and formSubtitle
@endif
@if(filled($headView))
    @include($headView)
@endif

$footerView or $formFooterTitle and $formFooterSubtitle

FooterTitle

  • $footerView = 'path/your-blade-view-name' @include a blade view in the $footerView form slot, above the buttons.
  • $formFooterTitle, displayed above the buttons if !$footerView
  • $formFooterSubtitle, displayed above the buttons, below the $formFooterTitle, if !$footerView
  • Styling in the config file
    • form-footer
    • form-footer-title
    • form-footer-sub-title

form-footer.blade.php

@if(empty($footerView) && ($formFooterTitle || $formFooterSubtitle))
//show formFooterTitle and formFooterSubtitle
@endif
@if(filled($footerView))
    @include($footerView)
@endif

$afterFormView

  • $afterFormView = 'path/your-blade-view-name'
  • @include a blade view after the form, below the buttons.
  • perfect place to include scripts in combination with some input attributes. See BaseField Styling and BaseField Attributes.
//in mount()
$this->afterFormView = 'scripts/name-field';

// in fields()
Input::make('Name')
    ->wire('wire:model.defer')
    ->rootAttr([
       'x-data' => "foo()",
       'class' => 'border rounded',
    ])
    ->inputAttr([
        'x-ref' => 'name',
    ])
    ->required(),

resources/views/scripts/name-field.blade.php

@once
@push('scripts')
<script>
    function foo() {
        //access this.$refs.name        
    }
</script>
@endpush
@endonce
Clone this wiki locally