0
votes

I am having a bit of trouble getting an updated form to fill out with the array of user names. To see the correct bit in action, please go here: [removed link]

As you can see when the page completes loading, there is an option for “Mortgage Advisor“ which is pre-loaded with the user’s name. This user’s name is associated with the agentId value that you see in the URL.

I am upgrading this site to joomla 2.5 and when I copy over this bit of code on to add the drop-down menu to the form, it does not pick up the list:

  <tr>

    <td><?php echo JText::_('RSM_FORM_TXT_AGENT'); ?>:</td>

    <td>

        <select name="userId" id="userId">

            <option value="" <?php if($row->userId == ""){echo " selected='selected'";} ?>></option>

            <?php foreach($agents as $agent){

                $agents = $database->loadObjectList();

                ?> <option value='<?php echo $agent->id; ?>' <?php if($_GET['agentId'] == $agent->id){echo "selected='selected'";} ?> ><?php echo $agent->firstname; ?> <?php echo $agent->lastname; ?></option>

            <?php }?>

        </select>

    </td>



</tr>

This is copied over from the 1.5 joomla site example, but like I said before it is not sending the value over. You can see an example of this output here:

[removed link]

Any idea on how I can pick up the values to then pass on after submit button click? Also, could it be that I have missed another area which is connected to this value? Thanks.

2
try <option value="<?php echo $agent->id; ?>" instead of <option value='<?php echo $agent->id; ?>' and let me knowswapnesh
just gave it a shot and unfortunately this change did not work. any other ideas?codacopia

2 Answers

0
votes

After looking at your code, if this is not a typo then i think this might be the area of your problem --

            <?php foreach($agents as $agent){

                $agents = $database->loadObjectList();

using $agents in your code now you are fetching the array from $agent->id; ???

Let me know if this is the error or not.

0
votes

I was not loading the database table that the names are being loaded from.... so I copied from the Joomla 1.5 code and added as below:

$database =& JFactory::getDBO();

$database->setQuery("SELECT id, firstname, lastname from `#__comprofiler` WHERE `approved` = 1 AND `confirmed` = 1 ORDER BY `firstname` ASC");

$agents = $database->loadObjectList();

that was the problem.