0

How can I get the backend user's name and output it on the backend form field using a partial.

Thanks enter image description here

enter image description here

Lindelwa
  • 27
  • 6

2 Answers2

0

// Returns the signed in user $user = BackendAuth::getUser();

// Returns the signed in user from a controller $user = $this->user;

Lindelwa
  • 27
  • 6
0

Every partials which are render in back-end has "user" object within in it.

and this object is pointing to current logged in back-end user.

so if you want to add that user's fisrt_name in partial you can do something like this.

<?= $this->user->first_name ?>

but from you code I can sense that you want to use use-name and try to use it as key for $value array and get inner value of $value array

so first {{ }} this will not work inside php tags, instead good news you can directly use php code there :)

your solution:

<?= $value[$this->user->fisrt_name] ?>

you can replace attribute first_name to another column attribute which will appropriate to you.

if any issue please do comment.

Hardik Satasiya
  • 9,547
  • 3
  • 22
  • 40