slamx_
Change active Tab via callback
Is it possible to change the Tab by dynamic value? I want to use Icons on the front-end to open a form inside a modal and want to show the selected Tab? Maybe something like:
$this->form->getComponent('tabCompName')->activeTab(3)
4 replies
Move Searchbar to Sidebar
Is it possible to add the searchbar on top of the Sidebar? The reason for this move is, that we add a notification tool inside the Topbar and on mobile there is not enough space for both, searchbar and notification badge.
6 replies
False/Null value not inside getState
In v2 the Form State of a toggle send also a false/null state inside the getState() function. In v3 they don't - is it possible to change inside the global form component settings?
The Form field is disabled based on a condition.
4 replies
How to call function inside custom form field
I'm new in writing a custom form field. I watched the laracast from Dan but I want to trigger some custom functions inside the Field Class. I tried a regular wire:click with naming the method but I get the following response:
Unable to call component method. Public method [$example] not found on component
This is my example form field:
namespace App\Forms\Components;
use Filament\Forms\Components\Field;
class CloudFileSelect extends Field
{
protected string $view = 'forms.components.cloud-file-select';
public function example()
{
dd('example');
}
}
And this is the view:
<x-dynamic-component
:component="$getFieldWrapperView()"
:field="$field"
>
<div class="z-10" x-data="{ state: $wire.$entangle('{{ $getStatePath() }}') }">
<button class="button hover:cursor-pointer" type="button" wire:click="example()">Open Example</button>
</div>
</x-dynamic-component>
I would be happy if someone can help me or give me a good source with a comprehensive example for writing my own field.60 replies
extraFieldWrapperAttributes does not exist
Hey I'm a bit confused, I try to use extraFieldWrapperAttributes on a TextInput like in the docs:
https://filamentphp.com/docs/3.x/forms/fields/getting-started#adding-extra-html-attributes
But I get the response:
Method Filament\Forms\Components\TextInput::extraFieldWrapperAttributes does not exist.
5 replies
Custom Listeners in v3
I want to create a dispatch inside a Form Field Action (like repeater::createItem), but how I can access the livewire instance like here in v2?
$livewire->emit('newRepeaterItemID', $newUuid);
I tried it via component, but it didn't work.
$component->dispatch('newRepeaterItemID', $newUuid);
Any Ideas how convert this v2 into v3? Maybe I'm on the wrong path 🙏
Here is a v2 Code-Snippet:
$this->registerListeners([
'repeater::createItem' => [
function (Repeater $component, string $statePath): void {
if ($statePath !== $component->getStatePath()) {
return;
}
$newUuid = (string) Str::uuid();
$livewire = $component->getLivewire();
data_set($livewire, "{$statePath}.{$newUuid}", []);
$component->getChildComponentContainers()[$newUuid]->fill();
$component->collapsed(false, shouldMakeComponentCollapsible: false);
$livewire->emit('newRepeaterItemID', $newUuid);
$livewire->emit('newRepeaterItem', $statePath);
},
],
2 replies
Fileupload - Error divison by zero
I use the following code for fileupload customization, but when I use Livewire\Features\SupportFileUploads\TemporaryUploadedFile I get a "divison by zero" error.
FileUpload::make('avatar')
->label('Avatar Upload')
->disk('s3')
->image()
->visibility('private')
->maxSize(1024)
->preserveFilenames()
->imageResizeTargetHeight(600)
->getUploadedFileNameForStorageUsing(function (TemporaryUploadedFile $file): string {
// store new file
$oriName = $file->getClientOriginalName();
$storeName = $file->getFilename();
$this->userAvatar = [
'user_id' => auth()->ufile()->id,
'file_name' => $oriName,
'file_path' => auth()->ufile()->filePath() . '/' . $storeName,
'is_public' => false,
'categories' => ['Avatar'],
'upload' => ['Avatar'],
];
return (string) str($file->getFilename());
})
->directory(auth()->ufile()->filePath()),
3 replies
use getFormSchema in v3
One question, because unfortunately it is not really clear from the documentation - is getFormSchema() now outdated or can it still be used after an update?
It would be great if other notes were also listed in the upgrade overview (e.g. changes such as modal labels modalSubmitActionLabel etc.).
3 replies
Select disabled not working
When I use the following code, the disabled only worked not with multiple(). Any tips to fix this?
Select::make('users')
->label(__('Users'))
->multiple()
->reactive()
->afterStateUpdated(function (Closure $set, $state) {
$set('user_group', null);
$set('select_all', false);
})
->required()
->disabled(function(Closure $get){
$multi = $get('multi_user');
if($multi){
if($this->userAllEdit){
return false;
} else {
return true;
}
} else {
return false;
}
})
->options($options)
2 replies
Re-Render Form Schema
How can I use a variable that is set in the Emit function in the form schema? The form is in a modal and when the modal is opened, a fill method is used to set the data (edit form). Depending on the authorization for the record, certain fields should now be set to disabled. Does anyone have a solution? Is it possible to re-render the schema with custom parameters?
14 replies
Unable to use TinyEditor Media Modal
I have the problem that I cannot use the media modals on a current Filament V2 project (e.g. the href for a link). The plugin that is used is: mohamedsabil83/filament-forms-tinyeditor (latest v1) @MohamedSabil83
5 replies
Table Action always the same record
I have the problem that my custom callback for the Action table always uses the first record. How can I fix this?
Action::make('edit')
->action(function (UserItem $record): void {
$this->emit('doEmitCallback', [
'file' => $record->id
]);
})
->color('secondary')
->icon('heroicon-s-pencil'),
14 replies
Repeater Event listener not working
I have tried to use the listener as described in the documentation, but it does not work. The repeater is inserted in a tab. Is there anything to consider here?
use Filament\Forms\Components\Component;
protected function setUp(): void
{
parent::setUp();
$this->registerListeners([
'repeater::createItem' => [
function (Component $component, string $statePath): void {
if ($component->isDisabled()) {
return;
}
if ($statePath !== $component->getStatePath()) {
return;
}
// ...
},
],
]);
}
2 replies