EleventhTower
EleventhTower
FFilament
Created by EleventhTower on 4/6/2024 in #❓┊help
Using Related Field Data in Validation Messages
Can anyone tell me how to pass related data into the Validation message? Currently, this works as I want it to; I just need a better error message.
Select::make('entity_type_id')
->label('Entity Type')
->relationship('entityType', 'name')
->required(),
TextInput::make('name')
->required()
->unique('entities', 'name')
->validationMessages([
'unique' => 'This {{I want to display entityType.name here}} already has an attribute with this name.',
])
->maxLength(255),
Select::make('entity_type_id')
->label('Entity Type')
->relationship('entityType', 'name')
->required(),
TextInput::make('name')
->required()
->unique('entities', 'name')
->validationMessages([
'unique' => 'This {{I want to display entityType.name here}} already has an attribute with this name.',
])
->maxLength(255),
4 replies
FFilament
Created by EleventhTower on 4/5/2024 in #❓┊help
Test Slideover is Visible
I want to test that a slideOver edit action is visible. I have this on my ViewRecord:
<?php

namespace App\Filament\Resources\EntityTypeResource\Pages;

use App\Filament\Resources\EntityTypeResource;
use App\Models\EntityType;
use Filament\Actions\EditAction;
use Filament\Resources\Pages\ViewRecord;

class ViewEntityType extends ViewRecord
{
protected static string $resource = EntityTypeResource::class;

protected function getHeaderActions(): array
{
return [
EditAction::make()
->slideOver()
->form(EntityType::getForm()),
];
}
}
<?php

namespace App\Filament\Resources\EntityTypeResource\Pages;

use App\Filament\Resources\EntityTypeResource;
use App\Models\EntityType;
use Filament\Actions\EditAction;
use Filament\Resources\Pages\ViewRecord;

class ViewEntityType extends ViewRecord
{
protected static string $resource = EntityTypeResource::class;

protected function getHeaderActions(): array
{
return [
EditAction::make()
->slideOver()
->form(EntityType::getForm()),
];
}
}
This is the PEST test I am trying to run:
it('renders the edit slideover', function () {
$entityType = EntityType::factory()->create();
livewire(ViewEntityType::class, ['record' => $entityType->getRouteKey()])
->mountAction(['edit'])
->callAction(['edit'])
->assertSee('Save changes');
});
it('renders the edit slideover', function () {
$entityType = EntityType::factory()->create();
livewire(ViewEntityType::class, ['record' => $entityType->getRouteKey()])
->mountAction(['edit'])
->callAction(['edit'])
->assertSee('Save changes');
});
I have tried multiple variations of this, but I need some more direction. Thanks.
2 replies