Why HtmlString not work in filamentphp
->afterStateUpdated(function ($state, callable $set, callable $get) {
self::updateRiskRates($state, $set, $get);
$value = RiskManagementRiskCalculationValue::whereIn('selectedTab', ['addition', 'multiplication'])->first();
if ($value) {
if ($value->selectedTab === 'addition') {
$inherentRiskRate = $get('likelihood') + $get('impact');
$htmlContent = new HtmlString('<div>Addition Calculation</div>') . $get('likelihood') . ' + ' . $get('impact') . ' = ' . $inherentRiskRate;
$set('culation', $htmlContent);
} elseif ($value->selectedTab === 'multiplication') {
$inherentRiskRate = $get('likelihood') * $get('impact');
$htmlContent = new HtmlString('<div>Multiplication Calculation</div>') . $get('likelihood') . ' * ' . $get('impact') . ' = ' . $inherentRiskRate;
$set('culation', $htmlContent);
}
}
})
![No description](https://cdn.answeroverflow.com/1260230895021981776/image.png)
Solution:Jump to solution
You shouldn't
$set
an HtmlString. It probably should be formatted when output8 Replies
what isn't working?
new HtmlString('<div>Addition Calculation</div>')
![No description](https://cdn.answeroverflow.com/1260240599227826196/image.png)
Is it a placeholder?
no custom filed
<x-dynamic-component
:component="$getFieldWrapperView()"
:field="$field"
>
<div x-data="{ state: $wire.$entangle('{{ $getStatePath() }}') }" class="label label-striped label-custom-alert {{ App::getLocale() === 'ar' ? 'bordermatrixr' : 'border-left-danger-matrix' }}">
<span x-text="state"></span>
</div>
</x-dynamic-component>
use
x-html
instead of x-text@Alnuaimi
![No description](https://cdn.answeroverflow.com/1260245130414129172/Screenshot_2024-07-09_at_16.43.54.png)
Solution
You shouldn't
$set
an HtmlString. It probably should be formatted when outputthanks ,It's working now