Autofocus only when on desktop & action is create
i have this field:
currently, is auto-focused, but i want only it to be auto-focused when the user is on a desktop device and the current action is the create action
10 Replies
at the moment i just found out this:
https://filamentphp.com/docs/3.x/forms/advanced#injecting-the-current-form-operation
but idk how to use it
Not sure about how to achive the desktop determination (maybe you could check via the user-agent or defer to a package like: https://github.com/phattarachai/laravel-mobile-detect)
As for implementation regarding the "create" action (https://filamentphp.com/docs/3.x/forms/advanced#injecting-the-current-form-operation):
mount
method, inject the Illuminate\Http\Request
and set the variable on the component itself with an attribute like Locked
(https://livewire.laravel.com/docs/locked)autofocus
closure.but the filament resource has mount method?
class ClientResource extends Resource
all calls seem static
cool, the operation thing πjust tried this, doesnt dd
also yeah, i know this package, similar to the one u shared - https://github.com/jenssegers/agent
but i mean, id like to do it via screen width
so i dont need packages, but idk if this can be done π€
argh, also tried:
->visibleFrom('md')
i got: Method Filament\Forms\Components\TextInput::visibleFrom does not exist.
i keep pushing hahabut in the create resource page i dont have the form fields, can i interact with them there?
@ericmp so sorry for the delay and misleading information;
no worries, oh hmmm so u can pass in the request too, interesting. im going to work around this. thanks π