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);
}
}
})
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>')
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
Solution
You shouldn't
$set
an HtmlString. It probably should be formatted when outputthanks ,It's working now