Changing password error "Email already exists"
I seem to be getting this "The email address has already been taken" when changing my passwords.
I have changed my user model to allow duplicate email addresses and use another uniques field 'name' for login. Not ideal but the way the client currently works we need to do it in the short term.
Everything works and I can create accounts with the same email address and users login with unique name fine.
The issue is that on the profile page the email field is checking for uniqueness, what os the best way to override that?
Solution:Jump to solution
just change the getEmailFormComponent() method:
```php
protected function getEmailFormComponent(): Component
{
return TextInput::make('email')...
9 Replies
Thanks @awcodes, I couldn't see how to remove uniqueness from the email field on the profile edit page. I think I need to create a custom edit profile page with a form in that. I'm just looking into that now. https://filamentphp.com/docs/3.x/panels/users#customizing-the-authentication-features
this is what you are looking for. it applies to any record field that needs to be unique.
Field::make('email')->unique(ignoreRecord: true)
it works with this from laravel: https://laravel.com/docs/10.x/validation#rule-unique
Laravel - The PHP Framework For Web Artisans
Laravel is a PHP web application framework with expressive, elegant syntax. We’ve already laid the foundation — freeing you to create without sweating the small things.
I don't want email to be unique, I want to remove the uniqueness. I have done this on all the user resouerce pages apart from the profile page.
sorry, misunderstood, you should just be able to extend the Profile Page and set your own email field there. then in the panel tell the profile method to use your class instead of Filament's default one.
I have got so far with extending the user profile page but I get a livewire error.
Unable to find component: [app.filament.auth.pages.edit-profile]
My code looks like this (Basically the basic page for testing)
The form loads but if you click save I get the error
Solution
just change the getEmailFormComponent() method:
leave everything else the same
this is actually the only method you would need in your custom class every thing else can stay in the base class