BBQfun
BBQfun
FFilament
Created by BBQfun on 3/20/2025 in #❓┊help
How to modify data before validation in simple(modal) resource
I have a resource pages, the beforeValidate() is work perfect
class CreateRole extends CreateRecord
{
protected function beforeValidate(): void
{
if (isset($this->data['role_name']) && is_string($this->data['role_name'])) {
$this->data['role_name'] = Str::squish($this->data['role_name']);
} else {
$this->data['role_name'] = null;
}
}
}

class EditRole extends EditRecord
{
protected function beforeValidate(): void
{
if (isset($this->data['role_name']) && is_string($this->data['role_name'])) {
$this->data['role_name'] = Str::squish($this->data['role_name']);
} else {
$this->data['role_name'] = null;
}
}
}
class CreateRole extends CreateRecord
{
protected function beforeValidate(): void
{
if (isset($this->data['role_name']) && is_string($this->data['role_name'])) {
$this->data['role_name'] = Str::squish($this->data['role_name']);
} else {
$this->data['role_name'] = null;
}
}
}

class EditRole extends EditRecord
{
protected function beforeValidate(): void
{
if (isset($this->data['role_name']) && is_string($this->data['role_name'])) {
$this->data['role_name'] = Str::squish($this->data['role_name']);
} else {
$this->data['role_name'] = null;
}
}
}
so it means in simple(modal) resource, there is no method to modify the data before validation? because there is only one file inside the pages folder
class ManagePosts extends ManageRecords
{

}
class ManagePosts extends ManageRecords
{

}
Thankyou toeknee, so it means when i use modal, afterStateUpdated is the only way to modify state before validation?
4 replies