Forums

Preselect a dropdown with the logged in user_name

Verreyt Luc 15 Sep, 2017
In the setup I placed Custom Code in the load Event to get user name who logged in at Joomla with following code
<?php 
$user = JFactory::getUser();
echo $user;
?>


I see on the form when executed that $user is known by testing with the echo command.

In the form I have a dropdown that is filled with data from a database. In the field Option I filled in
{var:read_data4}
. This is the name from the Read Data action in the load event. When executing the form I see al the names coming from the database. So far so good.

I like now to preselect the name from the user that is logged in, and known by $user->name.
There for I'm looking for a few days but can't find the solution for this.

Can anyone help me with this ?
Max_admin 29 Sep, 2017
Hi Verreyt,

In v6 you can do this by adding the following code to the "Selected values" box in the dropdown settings:
{user:name}


No php is needed.

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.