how to make a link field when user click on this it will redirect to the link?

or do we use any icon that shows us this is a link ?
No description
9 Replies
Patrick Boivin
Patrick Boivin15mo ago
But how does this work as a form field? How can you edit the field?
Ali Abbas
Ali AbbasOP15mo ago
@Patrick Boivin i am just want this as a text not field or icon when user click on this it should show in next tab i am using like this Select::make('supplier_id') ->label('Supplier') ->options(Supplier::all()->pluck('supplier_name', 'id')) ->required() ->afterStateUpdated(function (Closure $set, $state) { if ($state !== '') { $supplier = Supplier::find($state); if ($supplier) { $set('Link', $supplier->website); } } }) ->searchable() ->reactive() ->columns(2), TextInput::make('Link') ->hidden(fn (Closure $get) => $get('supplier_id') == '') ->columns(1),
Patrick Boivin
Patrick Boivin15mo ago
One idea is to use a Placeholder instead of a TextInput:
Placeholder::make('link')->content(function ($get) {
return new HtmlString(
$get('supplier_id') ? '<a href="..." target="_blank">...</a>' : ''
);
})
Placeholder::make('link')->content(function ($get) {
return new HtmlString(
$get('supplier_id') ? '<a href="..." target="_blank">...</a>' : ''
);
})
Ali Abbas
Ali AbbasOP15mo ago
@Patrick Boivin i am setting vlaue in link field from Select how can i use this value in href="..."
Patrick Boivin
Patrick Boivin15mo ago
Don't set it in the Select, move this logic inside of content()
AliBabba420
AliBabba42015mo ago
@Ali Abbas How did you get that tabs in form action
Ali Abbas
Ali AbbasOP15mo ago
can you plz provide me a example i am using use Filament\Forms\Components\Tabs;
AliBabba420
AliBabba42015mo ago
inside a edit form how
Ali Abbas
Ali AbbasOP15mo ago
@NÕØBÎTÅ Tabs\Tab::make('Supplier')->schema([ Repeater::make(name: 'productSuppliers') ->relationship() ->schema($this->_tabSupplierFields()) ->columns(3) ]), // End Supplier tab protected function mutateFormDataBeforeFill(array $data): array using this in edit page for data to populate @Patrick Boivin thanks this is working fine by using Placeholder also another way is TextInput::make('Link') ->url() ->suffixAction(fn (?string $state): Action => Action::make('visit') ->icon('heroicon-s-external-link') ->url( filled($state) ? "{$state}" : null, shouldOpenInNewTab: true, ), ) ->hidden(fn (Closure $get) => $get('supplier_id') == '') ->columns(1),
Want results from more Discord servers?
Add your server