Passing multidimensional object to get_string

Passing multidimensional object to get_string

by Helson C -
Number of replies: 2

Hello everyone.

global $USER;

$a->hello= "Hello";

$a->user = $USER;

$mform->addElement('static', 'element1', '', get_string('hellomsg', 'enrol_test', $a));

--

$string['some_string'] = '{$a->hello} {$a->user->firstname}';

--


Output:

Hello {$a->user->firstname}

Why I can't get the firstname ? 


Expected:

Hello firstNameHere


I try with var_dump and the $USER object is being passed correctly.


Thanks in advance!

Average of ratings: -
In reply to Helson C

Re: Passing multidimensional object to get_string

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Moodle simply doesn't support what you are trying to do.

If you want the firstname, write:

$a->firstname = $USER->firstname;

Then, in the language string, put:

{$a->firstname}