Alexandre
Alexandre
FFilament
Created by Rolland on 11/18/2024 in #❓┊help
No application encryption key has been specified
Hi, Do you have a value associated with APP_KEY in your .ENV file? If not, you can use the php artisan key:generate command to create it.
5 replies
FFilament
Created by NothingToSay on 11/12/2024 in #❓┊help
Disable back button for wizard on modal
Hi. You have this method : ->previousAction() So you can try that : ->previousAction(fn (Action $action): Action => $action->extraAttributes(['class' => 'hidden'])) Cf. https://github.com/filamentphp/filament/discussions/9942#discussioncomment-7702242
5 replies
FFilament
Created by dyo on 11/11/2024 in #❓┊help
Adjust the component height
And when you look in the inspector, can you see that the CSS class has been added?
8 replies
FFilament
Created by Alexandre on 9/3/2024 in #❓┊help
Incremental itemLabel for repeater
No description
7 replies
FFilament
Created by Asmit Nepali on 10/15/2024 in #❓┊help
File Upload Issue
The image sent is in base64. Try increasing the value of your client_max_body_size in php.ini (and maybe post_max_size too)
9 replies
FFilament
Created by Asmit Nepali on 10/15/2024 in #❓┊help
File Upload Issue
Do you have a particular error in your console?
9 replies
FFilament
Created by Asmit Nepali on 10/15/2024 in #❓┊help
File Upload Issue
Just to be sure, is the max file upload size value sufficient in your php.ini file?
9 replies
FFilament
Created by Alexandre on 9/3/2024 in #❓┊help
Incremental itemLabel for repeater
I found a solution on Github for those who are looking too :
->itemLabel(function ($state, $component) {
$key = array_search($state, $component->getState());
$index = array_search($key, array_keys($component->getState()));

return 'Réponse n°'.$index + 1;
})
->itemLabel(function ($state, $component) {
$key = array_search($state, $component->getState());
$index = array_search($key, array_keys($component->getState()));

return 'Réponse n°'.$index + 1;
})
And that work like expected 🥳 Source : https://github.com/filamentphp/filament/discussions/8565#discussioncomment-7031649
7 replies
FFilament
Created by Alexandre on 8/14/2024 in #❓┊help
Create resource not found
🤦‍♂️🤦‍♂️🤦‍♂️🤦‍♂️🤦‍♂️🤦‍♂️🤦‍♂️ Thanks, that was it and it works. Sorry and thanks again 😅
5 replies
FFilament
Created by Alexandre on 7/17/2024 in #❓┊help
afterStateUpdated not work on custom field
Okay, that's it. It works 🥳 Thank you so much for your help and patience Filament has an amazing community 🙏
14 replies
FFilament
Created by Alexandre on 7/17/2024 in #❓┊help
afterStateUpdated not work on custom field
Ah... I feel very stupid right now... 🫣 I'm sorry... I clicked on the label, which then selected the radio... Is it possible to have the afterStateUpdated called when the label is clicked? 🤔
14 replies
FFilament
Created by Alexandre on 7/17/2024 in #❓┊help
afterStateUpdated not work on custom field
14 replies
FFilament
Created by Alexandre on 7/17/2024 in #❓┊help
afterStateUpdated not work on custom field
Thanks again for your help. I just made the change. I don't get my DD() if I click on one of my radio buttons from my CylinderType input. However, I've noticed that if I click on any other input with a ->live() method, the DD() from my afterStateUpdated() appears.
14 replies
FFilament
Created by Alexandre on 7/17/2024 in #❓┊help
afterStateUpdated not work on custom field
Thanks for your reply 🙂 I've just tried it, but it's the same thing: when I click on one of my inputs, nothing happens...
CylinderType::make('content.cylinder_type.value')
->options(array(
__('users/requests.field.1') => __('users/requests.field.1'),
__('users/requests.field.2') => __('users/requests.field.2'),
__('users/requests.field.3') => __('users/requests.field.3')
))
->hiddenLabel()
->live()
->afterStateUpdated(function (
Set $set, $state
) {
dd("Don't work :( ");
})
->columnSpanFull()
CylinderType::make('content.cylinder_type.value')
->options(array(
__('users/requests.field.1') => __('users/requests.field.1'),
__('users/requests.field.2') => __('users/requests.field.2'),
__('users/requests.field.3') => __('users/requests.field.3')
))
->hiddenLabel()
->live()
->afterStateUpdated(function (
Set $set, $state
) {
dd("Don't work :( ");
})
->columnSpanFull()
Is there anything missing in my component view to make the afterStateUpdated() functional? My aim is to change the value of another field according to what we've chosen. Maybe is there any other way?
14 replies
FFilament
Created by Alexandre on 7/17/2024 in #❓┊help
afterStateUpdated not work on custom field
And the view :
@php
$id = $getId();
$statePath = $getStatePath();
$options = $getOptions();
@endphp

<x-dynamic-component :component="$getFieldWrapperView()" :field="$field">
<div
class="..."
x-data="{ state: $wire.$entangle('{{ $getStatePath() }}'), }"
>
@foreach ($options as $value => $label)
@php
$inputId = "{$id}-{$value}";
$shouldOptionBeDisabled = $isDisabled || $isOptionDisabled($value, $label);
@endphp
<label
for="{{ $inputId }}"
x-on:click="state = '{{ $value }}'"
class="..."
>
@if($value === __('users/requests.field.1') )
<img src="..."
alt="..."
height="200">
@elseif($value === __('users/requests.field.2') )
<img src="..."
alt="..." height="200">
@else
<img src="..."
alt="..." height="200">
@endif
<div class="...">
<input type="radio"
id="{{ $inputId }}"
value="{{ $value }}"
wire:model="{{ $getStatePath() }}"
x-model="state"
class="...">
<span class="...">{{ $value }}</span>
</div>
</label>
@endforeach
</div>
</x-dynamic-component>
@php
$id = $getId();
$statePath = $getStatePath();
$options = $getOptions();
@endphp

<x-dynamic-component :component="$getFieldWrapperView()" :field="$field">
<div
class="..."
x-data="{ state: $wire.$entangle('{{ $getStatePath() }}'), }"
>
@foreach ($options as $value => $label)
@php
$inputId = "{$id}-{$value}";
$shouldOptionBeDisabled = $isDisabled || $isOptionDisabled($value, $label);
@endphp
<label
for="{{ $inputId }}"
x-on:click="state = '{{ $value }}'"
class="..."
>
@if($value === __('users/requests.field.1') )
<img src="..."
alt="..."
height="200">
@elseif($value === __('users/requests.field.2') )
<img src="..."
alt="..." height="200">
@else
<img src="..."
alt="..." height="200">
@endif
<div class="...">
<input type="radio"
id="{{ $inputId }}"
value="{{ $value }}"
wire:model="{{ $getStatePath() }}"
x-model="state"
class="...">
<span class="...">{{ $value }}</span>
</div>
</label>
@endforeach
</div>
</x-dynamic-component>
14 replies
FFilament
Created by Kyle on 7/15/2024 in #❓┊help
FilePond seems to have a grid view feature. Is there any way to enable it in Filament?
👋 Look at the doc here : https://pqina.nl/filepond/docs/api/style/ Have you tried with CSS?
.filepond--item {
width: calc(50% - 0.5em);
}
.filepond--item {
width: calc(50% - 0.5em);
}
8 replies
FFilament
Created by Glebka on 7/12/2024 in #❓┊help
Fill custom edit page form with data
You can access your form using the mount() method. From there, you should be able to fill the fields with your record in this way:
public function mount(int | string $record): void
{
$this->record = LearningResource::findOrFail($record);
$this->fillForm();
}
public function mount(int | string $record): void
{
$this->record = LearningResource::findOrFail($record);
$this->fillForm();
}
6 replies
FFilament
Created by Jojo on 7/2/2024 in #❓┊help
Click record without jumping
on your resource class, add this : return $table->recordUrl(null) https://filamentphp.com/docs/3.x/tables/advanced#record-urls-clickable-rows
14 replies
FFilament
Created by Alexandre on 6/13/2024 in #❓┊help
Component not found on select with native(false) and searchable()
Unfortunately not 😥 I've removed native() and searchable() but no solutions yet. I can't understand why it's only on this field that the problem occurs.
6 replies
FFilament
Created by Sidji on 6/13/2024 in #❓┊help
Shared panel session
👋 I've similar case in my project (one panel for Users and another for admin and super_admin) and I wanted to use the same login form. Here's how I did it (it may not be the best way, but it works 😅) I use the method canAccessPanel in my User Model like this :
public function canAccessPanel(Panel $panel): bool
{
if ($panel->getId() === 'admin') {
return $this->hasAnyRole(['super_admin', 'admin']);
}

if ($panel->getId() === 'user') {
return $this->hasRole(['user']);
}

return false;
}
public function canAccessPanel(Panel $panel): bool
{
if ($panel->getId() === 'admin') {
return $this->hasAnyRole(['super_admin', 'admin']);
}

if ($panel->getId() === 'user') {
return $this->hasRole(['user']);
}

return false;
}
And in my web.php route file I've made a little change for the base URL :
Route::get('/', function () {
if (Filament::auth()->check()) {
$panelRedirect = Helpers::getPanelDashboardUrlFromUser();
if ($panelRedirect != null) {
return redirect()->to($panelRedirect);
}
}

return redirect()->to('/user/login');
})->name('home');

Route::get('/admin/login', function () {
return redirect()->to('/user/login');
})->name('filament.admin.auth.login');
Route::get('/', function () {
if (Filament::auth()->check()) {
$panelRedirect = Helpers::getPanelDashboardUrlFromUser();
if ($panelRedirect != null) {
return redirect()->to($panelRedirect);
}
}

return redirect()->to('/user/login');
})->name('home');

Route::get('/admin/login', function () {
return redirect()->to('/user/login');
})->name('filament.admin.auth.login');
And I've made a little helper to manage the redirection :
public static function getPanelDashboardUrlFromUser(): ?string
{
if (Filament::auth()->check()) {

$user = Filament::auth()->user();

$panelAdmin = Filament::getPanel('admin');
$panelUser = Filament::getPanel('user');

if ($user->canAccessPanel($panelAdmin)) {
return route('filament.admin.pages.dashboard');
} elseif ($user->canAccessPanel($panelUser)) {
return route('filament.user.pages.user-dashboard');
} else {
return null;
}
}

return null;
}
public static function getPanelDashboardUrlFromUser(): ?string
{
if (Filament::auth()->check()) {

$user = Filament::auth()->user();

$panelAdmin = Filament::getPanel('admin');
$panelUser = Filament::getPanel('user');

if ($user->canAccessPanel($panelAdmin)) {
return route('filament.admin.pages.dashboard');
} elseif ($user->canAccessPanel($panelUser)) {
return route('filament.user.pages.user-dashboard');
} else {
return null;
}
}

return null;
}
So, from the same form and according to your role, you're directed to the right panel. 👍
6 replies