cpereiraweb
cpereiraweb
Explore posts from servers
TLCTuto's Laravel Corner
Created by cpereiraweb on 8/29/2023 in #💡filament
Validation doesn't work on form created with createOptionForm
Folks, I used the createOptionForm function to enable a new record creation form in a select field. Unfortunately, on this form, the unique() validation is not working. I followed a tip from Povilas in the code below, also without success:
// Document comes from a Leandro Ferreira package for document fields in pt_BR
Document::make('cpf')
->label('CPF')
->live()
->cpf('999.999.999-99')
->dehydrateStateUsing(fn(string $state): string => preg_replace('/[.-]+/', '', $state))
->unique()
->required()
->live()
->afterStateUpdated(function (Forms\Contracts\HasForms $livewire, Document $component) {
$livewire->validateOnly($component->getStatePath());
}),
// Document comes from a Leandro Ferreira package for document fields in pt_BR
Document::make('cpf')
->label('CPF')
->live()
->cpf('999.999.999-99')
->dehydrateStateUsing(fn(string $state): string => preg_replace('/[.-]+/', '', $state))
->unique()
->required()
->live()
->afterStateUpdated(function (Forms\Contracts\HasForms $livewire, Document $component) {
$livewire->validateOnly($component->getStatePath());
}),
It only validates required and not unique. When submitting the form, the key violation error occurs, as I tested an already registered document number. Can anyone tell me where I'm going wrong?
7 replies
FFilament
Created by cpereiraweb on 8/17/2023 in #❓┊help
Accessor as a column in the Attach action on a RelationManager
Guys, I need help with a question: I have a RelationManager and I would like the Attach action form to display a combination of id and name of the associated model. I created an Accessor in the model, inserted it in the $appends array and used this Accessor as a column in the creation of the RelationManager. I did not succeed. Can anyone point me to a documentation link or other resource that points me in the right direction? Thank you all in advance for your help.
8 replies
FFilament
Created by cpereiraweb on 3/16/2023 in #❓┊help
Validation rule active only when creating a record
Guys, I researched a lot about this but I didn't find references, so I ask you for help: and a form, I need a validation rule to be applied only when I'm creating a new record. If I am editing this rule should not be considered. Can anyone point me in the correct direction? Thank you all in advance!
12 replies