Warp Input demo — phone numbers, addresses, money, IDs, signatures and form helpers for Filament. Change or delete anything; the data is reset every hour. warpui.com About Warp Input Docs Ask a question Support
Skip to content

Duplicate warnings

->warnDuplicates() works on EmailInput, PhoneInput, UrlInput and WarpTextInput. When you leave the field, it looks for other records with the same value and names them under the field, with a link to open each one. It is only a warning: the form still saves. These fields look through the 24 customers of the Customers list. In a panel with Filament tenancy, only the current tenant’s records are searched.

Email addresses

EmailInput::make('email')->warnDuplicates(Customer::class, 'email') compares with the customers’ email column. Capital letters don’t matter.

Note: Try it

Type ORDERS@BaysideGrocers.com and click outside the field. “Another customer already has this email address: Bayside Grocers Open” appears. Open goes to that customer in a new tab.

Phone numbers

The typed number is turned into its saved form first, so 617-555-0142, (617) 555-0142 and +1 617 555 0142 all find the saved +16175550142.

Note: Try it

Type 617-555-0142 and click outside the field. Bayside Grocers is named under it.

Web addresses

https:// is added and the site name is lower-cased before comparing, so BaysideGrocers.com finds the saved https://baysidegrocers.com.

Note: Try it

Type BaysideGrocers.com and click outside the field. Bayside Grocers is named under it.

Text fields

WarpTextInput can warn too, for example when a customer with the same company name already exists.

Note: Try it

Type Bayside Grocers and click outside the field. “Another customer already has the same value” appears.

Many matches

At most three records are named; the rest are counted (“and 10 more”). This field compares with the customers’ state.

Note: Try it

Type MA (Massachusetts) and click outside the field. Three customers are named, followed by “and 10 more”.

The name shown for each record

label: fn (Customer $record) => … decides the name in the notice. Without it, the resource’s record title is used (here the customer name).

Note: Try it

Type orders@baysidegrocers.com and click outside the field. The notice says C-1001 Bayside Grocers: the customer code comes first.

Where “Open” goes

Without settings, “Open” goes to the record’s edit page (or view page) when you may open it. url: fn (Customer $record) => … sends it somewhere else; this field opens the Customers list searched for the name.

Note: Try it

Type 617-555-0142 and click outside the field, then click Open. The Customers list opens in a new tab, showing only Bayside Grocers.

Search only some records

query: fn (Builder $query) => $query->where('country', 'US') narrows the search, for example to leave out archived records. This field only looks at customers in the United States.

Note: Try it

Type oliver@thamestea.co.uk (a customer in the United Kingdom) and click outside the field: no notice. Then type orders@baysidegrocers.com: Bayside Grocers is named.

The words in the notice

modelLabel: and pluralModelLabel: change the word in the notice. Without them, the resource’s labels are used (“customer”, “customers”).

Note: Try it

Type orders@baysidegrocers.com and click outside the field. The notice says “Another account already has this email address”.

Turn the warning on and off

condition: turns the warning on or off, with true/false or a function. Here the switch above the field decides.

Note: Try it

Type orders@baysidegrocers.com and click outside the field: Bayside Grocers is named. Turn the switch off, type hello@beaconhillbakery.com and click outside the field: no notice.

Refuse duplicates

The warning never stops saving. To refuse a duplicate, add Laravel’s rule as well: ->unique(Customer::class, 'email').

Note: Try it

Type orders@baysidegrocers.com and press “Show what would be saved”: the notice and an error appear, and nothing is saved. new@harborsupply.com is saved.

The record being edited is left out

When you edit a record, the field doesn’t warn about the record itself, only about the others. The Customers edit form uses ->warnDuplicates(Customer::class) on Email, Phone and Website.

Note: Try it

Open Customers and then Bayside Grocers. Click in Email (orders@baysidegrocers.com) and then outside it: no notice. Change it to hello@beaconhillbakery.com: Beacon Hill Bakery is named.