Manuk Minasyan
Manuk Minasyan
FFilament
Created by Manuk Minasyan on 1/13/2025 in #❓┊help
How to pass a section_id parameter to a action when creating a record?
I will try it. Thank you
12 replies
FFilament
Created by Manuk Minasyan on 1/13/2025 in #❓┊help
How to pass a section_id parameter to a action when creating a record?
Are you mean create different component for this purpose? Am I right?
12 replies
FFilament
Created by Manuk Minasyan on 1/13/2025 in #❓┊help
How to pass a section_id parameter to a action when creating a record?
How to do this? I couldn't find anything in the documentation. When I use action without form, this is simple to pass arguement and get it, but with forms this is difficult. in ->action method how to get form data and arguments that I passed from the view?
12 replies
FFilament
Created by Manuk Minasyan on 1/13/2025 in #❓┊help
How to pass a section_id parameter to a action when creating a record?
@foreach ($this->sections as $section)
<x-filament::section x-sortable-item="{{ $section['id'] }}" compact>
<x-slot name="footerActions">
<x-filament::button size="sm" wire:click="mountAction('createFieldAction', { sectionId: 12345 })">
Create field
</x-filament::button>
</x-slot>
</x-filament::section>
@endforeach
@foreach ($this->sections as $section)
<x-filament::section x-sortable-item="{{ $section['id'] }}" compact>
<x-slot name="footerActions">
<x-filament::button size="sm" wire:click="mountAction('createFieldAction', { sectionId: 12345 })">
Create field
</x-filament::button>
</x-slot>
</x-filament::section>
@endforeach
12 replies
FFilament
Created by Manuk Minasyan on 1/13/2025 in #❓┊help
How to pass a section_id parameter to a action when creating a record?
public function createFieldAction(): Action
{
return Action::make('createField')
->size(ActionSize::ExtraSmall)
->label('Create Field')
->form(function(){
return [
Forms\Components\TextInput::make('name')
->required()
->live(onBlur: true)
->maxLength(50),
];
})
->fillForm([
'entity_type' => $this->currentEntityType,
])
->mutateFormDataUsing(function (array $data): array {
if (Utils::isTenantEnabled()) {
$data[config('custom-fields.column_names.tenant_foreign_key')] = Filament::getTenant()?->id;
}

$data['custom_field_section_id'] = null; // I need add section_id here

return $data;
})
->action(fn(array $data) => CustomField::create($data))
->slideOver();
}
public function createFieldAction(): Action
{
return Action::make('createField')
->size(ActionSize::ExtraSmall)
->label('Create Field')
->form(function(){
return [
Forms\Components\TextInput::make('name')
->required()
->live(onBlur: true)
->maxLength(50),
];
})
->fillForm([
'entity_type' => $this->currentEntityType,
])
->mutateFormDataUsing(function (array $data): array {
if (Utils::isTenantEnabled()) {
$data[config('custom-fields.column_names.tenant_foreign_key')] = Filament::getTenant()?->id;
}

$data['custom_field_section_id'] = null; // I need add section_id here

return $data;
})
->action(fn(array $data) => CustomField::create($data))
->slideOver();
}
12 replies
FFilament
Created by Gush on 11/21/2023 in #❓┊help
table layout without removing the column names row?
🥳
5 replies