Present a different Filament Form for mobile users

Dec 14, 2022
Andreas Kviby
Form builder

How to present a different Filament Form for mobile users

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.

So we needed a quick way to present another form on mobile

I have no idea if this is the weirdest solution but it works like a charm for us.

namespace 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.

Override the getFormSchema

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…