Custom HTML

Added v4.1.18
Column Type none

This field allows you to use a blade template to render any custom content.

You can use setView to provide the name of a Blade template that will be used to render the data. This should be a full Blade name. E.g. for resources/views/custom-fields/account the name should be custom-fields.account.

You can use setDataGetter to provide a callable to get extra data. This callable will be passed the model that is being editted as $item. This should return an array that will be spread and passed to your view.

Limitations

Due to a security feature of Vue, you cannot use other Vue components within your custom view - it must be static HTML only.

Example

Crud config

CustomHTMLField::make('my_custom_field')
  ->view('my-custom-field')
  ->dataGetter(function ($item) {
      return [
          'name' => $item->name,
          'url' => $item->url
      ];
  }),

my-custom-field.blade.php

<div>
  <a href="{{ $url }}">{{ $name }}</a>
</div>