You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The ModuleController method getForm() runs before any middleware is run.
Why is that a problem?
It makes it impossible to modify the form based on user.
// example 1: Not every field available to every user
if (Auth::user()->hasPermissionTo('admin'))
$form-add(Input::make()->name('admin_only_field'));
// example 2: Select options based on user
$form->add(Select::make()->name('posts')->options(Options::make([ Auth::user()->posts->map(fn($p) => Option::make([$p->id, $p->title])) ])));
Both of these do not work, because Auth::user() is not available (yet).
Steps to reproduce
add dd(Auth::id()) to the getForm method
Expected result
I get a dd with the value 1 (id of the current user)
Description
The ModuleController method getForm() runs before any middleware is run.
Why is that a problem?
It makes it impossible to modify the form based on user.
Both of these do not work, because Auth::user() is not available (yet).
Steps to reproduce
add
dd(Auth::id())
to the getForm methodExpected result
I get a dd with the value 1 (id of the current user)
Actual result
I get a dd with the value null
Versions
Twill version: 3.3.1
Laravel version: 11.0
PHP version: 8.2
Database engine: MySQL (Xampp)
Note
I would also be content with some kind of hack to achieve this behavior, but I couldn't figure out which vendor files to overwrite for that.
The text was updated successfully, but these errors were encountered: