I am having issues with the creation of a template which is supposed to show a dropdown where a user can select from a list of symbols of the stocks which he/she wants to sell. I am employing the following approach to do this: First I am making a call to query() function (in controller) to have the symbols of all the stocks a user owns in a two-dimensional array which I am naming to be $symbols. Then I am passing this array to a template to be rendered via render() function. Then to create a dropdown list of the symbols, I am doing something like the following in the template

    <select name = "symbol">
    <?php foreach ($symbols as $symbol): ?>
        <option value = "<?= $symbol["symbol"] ?>"></option>
    <?php endforeach ?>

The problem is that the code above is producing an empty dropdown menu, even though when I do dump($symbols), it prints a two dimensional array with all the symbols of the stock the user owns for the same user. Where am I messing the things up?


Try the following

<option value="<?= $symbol["symbol"] ?>"><?= $symbol["symbol"] ?></option>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .