
Summary
Social profile link editor with a platform picker, one URL row per platform, per-platform hostname validation, optional custom platforms, row reordering, and URL auto-formatting on blur. Client-side validation mirrors server rules and blocks form submit when rows are invalid (same pattern asScheduleField).
Basic usage
State format
Each link is a list item withplatform and url keys. Platform values match built-in enum slugs (instagram, x, linkedin, …) or custom platform value strings.
Minimal example
In-progress row (empty URL kept for validation)
While editing, rows with a selected platform but empty URL remain in Livewire state so server and client validation can report required errors:dehydrate), rows with empty URLs are stripped — only complete links persist.
Legacy associative map (enum platforms only)
Default platforms
Whenplatforms() is not set, all built-in platforms from SocialPlatform::defaults() are available:
instagram, x, linkedin, youtube, facebook, tiktok, github, telegram, whatsapp, pinterest, threads, discord, messenger, reddit, twitch, vimeo, vk, website
Use excludePlatforms() to remove entries from this default set without building a full whitelist.
Configuration API
All methods acceptClosure for dynamic configuration.
platforms(array|Closure|null $platforms)
Whitelist which platforms appear in the picker. Accepts SocialPlatform enum cases and/or string values (including custom platform values defined via customPlatforms()).
Default: null (use defaults minus exclusions, plus custom platforms).
excludePlatforms(array|Closure $platforms)
Exclude platforms from the default set when platforms() is not configured.
Default: [].
customPlatforms(array|Closure $platforms)
Add or override platform metadata. Each entry is an array (or resolved from a Closure) with:
Definitions are represented server-side by
SocialPlatformDefinition.
platforms() is set, only matching custom entries are included.
maxLinks(int|Closure|null $max)
Cap how many platform rows can be added. When reached, the picker shows a “all platforms added” message.
Default: null (unlimited, still one row per platform).
reorderable(bool|Closure $enabled = true)
Show up/down chevron buttons on each row to change display order.
Default: false. Enable explicitly:
autoFormatUrls(bool|Closure $enabled = true)
On URL input blur: trim whitespace and prepend https:// when no scheme is present.
Default: true.
variant(string|Closure $variant)
Visual variant passed to shared flex text input tokens.
Default: primary. Allowed: primary, secondary, soft, flat, ghost.
size(string|Closure $size)
Control density via HasControlSize.
Default: md.
readOnly() / disabled()
Standard Filament interaction states — picker, add, remove, reorder, and URL inputs become non-interactive.
required()
Field is empty when no rows have a non-empty URL after normalization. Rows with platform selected but empty URL fail validation.
focusOutline(bool|Closure $enabled = true)
Show focus ring on URL input shells (HasFieldFocusOutline).
Public helper methods
Validation
Server (SocialLinkValidator)
Row errors are wrapped with
social_links.validation.row (:platform: :message).
Built-in host rules mirror SocialPlatform::hostPatterns(). Custom platforms use their hosts array. website and custom entries with empty hosts accept any valid http(s) URL.
Client (Alpine + social-link-validation.js)
Same rules using dynamic hosts from getPlatformDefinitions(). On form submit (capture phase):
showValidationErrors = truevalidateAllRows()- If errors exist:
preventDefault(),stopImmediatePropagation(), sync first error to Livewire via$wire.addError(statePath, message)
ScheduleField submit guard pattern.
Recipes
CMS footer — small whitelist + cap
Broker profile — required with auto-format
Exclude niche platforms from defaults
Fediverse / custom brand
Read-only display on view page
Dynamic platform list from tenant settings
Eloquent model persistence
UI behaviour
CSS classes
Assets
Registered in
FlexFieldAssets. Blade includes load-stylesheet partial and x-load Alpine component.
PHP support classes
JavaScript modules
Exported test helpers:
collectSocialLinkRowErrors, hasSocialLinkValidationErrors, firstSocialLinkValidationError, dehydrateSocialLinksState, formatSocialLinkUrl.
Testing
Playground
Slug:social-links-field
/admin/flex-fields-playground/social-links-field — see Playground.