octobercmsoctobercms-backendoctober-partial

October CMS backend form field get backend username


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


Solution

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