F
Filament12mo ago
hpsi

Page with 3 forms, problem with selectData

Hey, I create my first custom page in filament and now I have issue My issue is: After I pick data form select and I will submit changes i cannot find selectedData In my page I have [PHP file], I will focus on one of the custom form (compnyForm)
class ManageCourseForm extends Page implements HasForms
{
use InteractsWithForms;

[...]
public array $dataCompany = [];
protected function getForms(): array
{
return [
'courseForm',
'companyForm',
'employeeForm',
];
}
public function companyForm(Form $form): Form
{
return $form
->schema([
Select::make('addCompanyEmployee')
->options($this->companiesData)
->label('choose company')
->searchable()
->multiple(),
])
->statePath('dataCompany')
->operation('create');
}

protected function getAddAllEmployeesFromCompanyActions(): array
{
return [
Action::make('addAllEmployeeFromCompanyAction')
->label('Dodaj wszystkich pracowników firmy')
->submit('addCompanyEmployeesForm')
];
}

public function addCompanyEmployeesForm()
{
/** @var Form $form */
$form = $this->companyForm;
dd($this->dataCompany, $form->getState());
}
class ManageCourseForm extends Page implements HasForms
{
use InteractsWithForms;

[...]
public array $dataCompany = [];
protected function getForms(): array
{
return [
'courseForm',
'companyForm',
'employeeForm',
];
}
public function companyForm(Form $form): Form
{
return $form
->schema([
Select::make('addCompanyEmployee')
->options($this->companiesData)
->label('choose company')
->searchable()
->multiple(),
])
->statePath('dataCompany')
->operation('create');
}

protected function getAddAllEmployeesFromCompanyActions(): array
{
return [
Action::make('addAllEmployeeFromCompanyAction')
->label('Dodaj wszystkich pracowników firmy')
->submit('addCompanyEmployeesForm')
];
}

public function addCompanyEmployeesForm()
{
/** @var Form $form */
$form = $this->companyForm;
dd($this->dataCompany, $form->getState());
}
Now View:
<x-filament-panels::form wire:submit="addCompanyEmployeesForm">
{{ $this->companyForm }}
<x-filament-panels::form.actions
:actions="$this->getAddAllEmployeesFromCompanyActions()"
/>
</x-filament-panels::form>
<x-filament-panels::form wire:submit="addCompanyEmployeesForm">
{{ $this->companyForm }}
<x-filament-panels::form.actions
:actions="$this->getAddAllEmployeesFromCompanyActions()"
/>
</x-filament-panels::form>
In attachments I'd send 2 screens with the form and what I got when I try get selected Data What I would like to get: After pick N-companies in select and press the button save i would like to get IDs (keys) of selected records - how to do it ?
No description
No description
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server