displaying address in filament form

Forms\Components\View::make('same_shipping_notice')
->content(fn (Forms\Get $get) => '
<div class="space-y-1">
<strong>Same as shipping address:</strong>
<div>' . e($get('shipping_address')) . '</div>
<div>' . e($get('shipping_postal_code')) . ' ' . e($get('shipping_city')) . '</div>
<div>' . e($get('shipping_country')) . '</div>
</div>
')
->visible(fn (Forms\Get $get) => $get('use_shipping_address'))
->columnSpanFull(),
Forms\Components\View::make('same_shipping_notice')
->content(fn (Forms\Get $get) => '
<div class="space-y-1">
<strong>Same as shipping address:</strong>
<div>' . e($get('shipping_address')) . '</div>
<div>' . e($get('shipping_postal_code')) . ' ' . e($get('shipping_city')) . '</div>
<div>' . e($get('shipping_country')) . '</div>
</div>
')
->visible(fn (Forms\Get $get) => $get('use_shipping_address'))
->columnSpanFull(),
why is this not working
5 Replies
raheel3031
raheel3031OP2w ago
anyone?
Jo
Jo2w ago
I don't think there is any content() method on the View component. I would usually do something like View::make('filament.forms.component.shipping-notice') and then make a resources/views/filament/forms/components/shipping-notice.blade.php file with your HTML inside it. Then you can put something like this into your blade:
<div class="space-y-1">
<strong>Same as shipping address:</strong>
<div>{{ $getRecord()->shipping_address }}</div>
<div>{{ $getRecord()->postal_code }} {{ $getRecord()->shipping_cit
y }}</div>
<div>{{ $getRecord()->shipping_country }}</div>
</div>
<div class="space-y-1">
<strong>Same as shipping address:</strong>
<div>{{ $getRecord()->shipping_address }}</div>
<div>{{ $getRecord()->postal_code }} {{ $getRecord()->shipping_cit
y }}</div>
<div>{{ $getRecord()->shipping_country }}</div>
</div>
raheel3031
raheel3031OP2w ago
i am trying to this inside the customer resource
No description
raheel3031
raheel3031OP2w ago
anyone?
rhysleesdev
rhysleesdev2w ago
As @Jo said, there is no content method in View, you should use ->view('path.to.blade.view') then define your content in the file https://filamentphp.com/docs/3.x/forms/layout/custom

Did you find this page helpful?