F
Filamentβ€’7mo ago
Quin.

put 2 values in to one Textinput

Ello, i have the terms and categories. but i wanted to make a option avaible so you can set the full domain in once
public static function form(Form $form): Form
{
return $form->schema([
Select::make('categories')
->multiple()
->options(fn (): array => Category::orderBy('id', 'asc')->pluck('name', 'id')->toArray())
->getSearchResultsUsing(fn (string $search): array => Category::where('name', 'like', "%{$search}%")->limit(50)->pluck('name', 'id')->toArray()),
TagsInput::make('terms'),
TextInput::make('fulldomain'),
]);
}
public static function form(Form $form): Form
{
return $form->schema([
Select::make('categories')
->multiple()
->options(fn (): array => Category::orderBy('id', 'asc')->pluck('name', 'id')->toArray())
->getSearchResultsUsing(fn (string $search): array => Category::where('name', 'like', "%{$search}%")->limit(50)->pluck('name', 'id')->toArray()),
TagsInput::make('terms'),
TextInput::make('fulldomain'),
]);
}
So like terms '.' categories for example filament.com so it has the term and categorie but in one textinput
Solution:
Already fixed it with a other solution πŸ˜„ I maked a extra string column and then in a other function seperated the string in to two variables and then worked my way
Jump to solution
4 Replies
DrByte
DrByteβ€’7mo ago
Do you mean like ->getDefaultState(fn(Get $get): string => $get('terms') . $get('categories')) The problem there is that categories in your example is a multiple() Select, so I'm not sure what $get will return. https://filamentphp.com/docs/3.x/forms/advanced#injecting-the-state-of-another-field
Quin.
Quin.β€’7mo ago
You can't give a closure to getDefaultState()
DrByte
DrByteβ€’7mo ago
Okay, then explore the example for auto-generating a slug for a blog post title: https://filamentphp.com/docs/3.x/forms/advanced#generating-a-slug-from-a-title
Solution
Quin.
Quin.β€’7mo ago
Already fixed it with a other solution πŸ˜„ I maked a extra string column and then in a other function seperated the string in to two variables and then worked my way
Want results from more Discord servers?
Add your server
More Posts