F
Filamentβ€’3mo ago
devpoolxx

Custom page with form and select input

I have this custom page:
<?php

namespace App\Admin\Resources\TalentResource\Pages;

use App\Admin\Resources\TalentResource;
use App\Models\Skill;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Forms\Form;
use Filament\Resources\Pages\Page;
use Illuminate\Contracts\View\View;

class ReviewTalent extends Page
{
use InteractsWithForms;

protected static string $resource = TalentResource::class;

protected static string $view = 'admin.resources.talent-resource.pages.review-talent';

public $first_name;
public $content;

public function mount(): void
{
$this->first_name = 'testing12312';
}

protected function getFormSchema(): array
{
return [
Select::make('skill_ids')
->multiple()
->label('Skills')
->columnSpanFull()
->getSearchResultsUsing(fn (string $search): array => Skill::where('value', 'ilike', "%{$search}%")->limit(40)->pluck('value', 'id')->toArray())
->getOptionLabelsUsing(fn (array $values): array => Skill::whereIn('id', $values)->pluck('value', 'id')->toArray())
->required()
];
}

public function submit()
{
dd($this->form->getState());
}
}
<?php

namespace App\Admin\Resources\TalentResource\Pages;

use App\Admin\Resources\TalentResource;
use App\Models\Skill;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Forms\Form;
use Filament\Resources\Pages\Page;
use Illuminate\Contracts\View\View;

class ReviewTalent extends Page
{
use InteractsWithForms;

protected static string $resource = TalentResource::class;

protected static string $view = 'admin.resources.talent-resource.pages.review-talent';

public $first_name;
public $content;

public function mount(): void
{
$this->first_name = 'testing12312';
}

protected function getFormSchema(): array
{
return [
Select::make('skill_ids')
->multiple()
->label('Skills')
->columnSpanFull()
->getSearchResultsUsing(fn (string $search): array => Skill::where('value', 'ilike', "%{$search}%")->limit(40)->pluck('value', 'id')->toArray())
->getOptionLabelsUsing(fn (array $values): array => Skill::whereIn('id', $values)->pluck('value', 'id')->toArray())
->required()
];
}

public function submit()
{
dd($this->form->getState());
}
}
with this blade component
<x-filament-panels::page>
<x-filament-panels::form wire:submit="submit">
{{ $this->form }}
<div>
<x-filament::button type="submit" size="sm">
Submit
</x-filament::button>
</div>
</x-filament-panels::form>
</x-filament-panels::page>
<x-filament-panels::page>
<x-filament-panels::form wire:submit="submit">
{{ $this->form }}
<div>
<x-filament::button type="submit" size="sm">
Submit
</x-filament::button>
</div>
</x-filament-panels::form>
</x-filament-panels::page>
The problem is the multiple option on Select component, whenever I type on the field, it throws ComponentNotFoundException..
Solution:
probably the statePath πŸ‘
Jump to solution
3 Replies
LeandroFerreira
LeandroFerreiraβ€’3mo ago
public $skill_ids;
devpoolxx
devpoolxxβ€’3mo ago
@Leandro Ferreira thank you! I figured this out that i've been doing the pages & component logic incorrect. I just followed this: https://filamentphp.com/docs/3.x/actions/adding-an-action-to-a-livewire-component
Solution
LeandroFerreira
LeandroFerreiraβ€’3mo ago
probably the statePath πŸ‘
Want results from more Discord servers?
Add your server
More Posts
Attach file with original name to mail throws exceptionHello, I am trying for hours now to attach files to a mail, but without success. I am using the filStyling forms modal forms created with createOptionsForm()I have a modal for creating contacts, if a company does not exist, I want to be able to create on onHow to create a website and have the filamentphp as SASS product?Hi guys, I'd like to create a website with **statamic cms** (laravel) and also give access to filameUnable to set checkbox default value to trueI have this but it's unchecked: ```php Forms\Components\Checkbox::make('is_admin') ->inline(trueSection with reactive fields forces collapse after field value changes.I have a use case where I would want the heading of Section to reflect values of fields under it. ThTable with a modal action that should contain a custom table-like form, is that even possible?I have a table showing users, with an Action that opens a modal. I want the modal to contain a list Admin PanelIf the Admin is logged in currently in a session and the super admin Deactivates the admin's accountIs it possible for filament that I will show all the data in different panel? my foreign key is id.The Accruals table will also be shown in Draft Bill table , the foreign id is the reference number.How can i change this default text into popup Relationship?Hi! someone can help me? I did'nt find this into the documentation how to change this text (yelow) wHow can i remove this default label text in resourceHow can i remove this default label text in resource