Skip to content

Commit ab5430c

Browse files
committed
Update columnSpan and render html on label
1 parent a49fca3 commit ab5430c

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/Filament/Resources/FilamentFormResource/RelationManagers/FilamentFormFieldsRelationManager.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ public function form(Schema $schema): Schema
4343
->sortBy(fn ($label, $key) => $label)
4444
->toArray();
4545
})
46+
->columnSpan(function ($state) {
47+
if (! empty($state) && FilamentFieldTypeEnum::fromString($state)->hasOptions()) {
48+
return 1;
49+
}
50+
51+
return 2;
52+
})
4653
->required()
4754
->live(),
4855
Textarea::make('label')

src/Livewire/FilamentForm/Show.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Filament\Forms\Contracts\HasForms;
88
use Filament\Schemas\Schema;
99
use Illuminate\Support\Facades\Auth;
10+
use Illuminate\Support\HtmlString;
1011
use Livewire\Component;
1112
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
1213
use Livewire\Features\SupportFileUploads\WithFileUploads;
@@ -81,7 +82,7 @@ public function getFormSchema(): array
8182
$subFieldComponent = FilamentFieldTypeEnum::fromString($subField['type'])->className()::make($subFieldId);
8283

8384
if (isset($subField['label'])) {
84-
$subFieldComponent = $subFieldComponent->label($subField['label']);
85+
$subFieldComponent = $subFieldComponent->label(new HtmlString($subField['label']));
8586
}
8687

8788
if (isset($subField['required']) && $subField['required']) {
@@ -119,7 +120,7 @@ public function parseField(Field $filamentField, array $fieldData): Field
119120
{
120121
if (isset($fieldData['label'])) {
121122
$filamentField = $filamentField
122-
->label($fieldData['label']);
123+
->label(new HtmlString($fieldData['label']));
123124
}
124125

125126
if (isset($fieldData['required']) && $fieldData['required']) {

0 commit comments

Comments
 (0)