Adding data to block forms

When needed you can expose additional data to block forms using a Block class.

Warning

The getFormData is only called once per module form and is not context aware.

1<?php
2 
3namespace App\Twill\Block;
4 
5use A17\Twill\Services\Blocks\Block;
6 
7class TextBlock extends Block
8{
9 public function getFormData(): array
10 {
11 return ['bar' => 'foo'];
12 }
13}

Now in your form you can use it as:

1@twillBlockTitle('Text')
2@twillBlockIcon('text')
3@twillBlockGroup('app')
4 
5@if ($bar === 'foo')
6... Conditional form fields
7@endif