We have a lot of forms that are used by different users on different platforms. Every time a mobile user uses our app we want to minimize the numbers of fields, we want to display Cards instead of Tabs and so on.
I have no idea if this is the weirdest solution but it works like a charm for us.
<?phpnamespace App\Http\Helpers;class StafeHelper{ public static function isMobile() { return is_numeric(strpos(strtolower($_SERVER["HTTP_USER_AGENT"]), "mobile")); }}
We created a small helper in our project called StafeHelper.php and we can now use that inside Filament Forms.
It will return true if client is on mobile.
So we override the getFormSchema inside our Create, Edit resource pages and use it like below.
protected function getFormSchema(): array { if (StafeHelper::isMobile()) { return $this->getMobileFormSchema(); } return $this->getDesktopSchema(); }
Works like a charm, please comment below.
No comments yet…