N
N
Nikolai Gromov2017-01-09 07:17:50
PHP
Nikolai Gromov, 2017-01-09 07:17:50

How to make a loop in smarty?

Hello. I'm trying to make an online store, and for authorization, registration and personal account, the select tag in the form is used.

<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6 highheader2">
                {foreach $rsAuth as $item name=auth}
                    <form action="{$item['route']}" method="post">                        
                        <select name="auth">
                            {$smarty.foreach.auth.iteration}
                                <option value="{$item['name']}">{$item['name']}</option>                            
                        </select>    
                    </form>
                {/foreach}
            </div>

I need the form to redirect to the appropriate page: registration or authorization, etc. via action. And so I do not know how to make a cycle that the form would enter into it. In the form as now I have three selects. Understand to me one select with three option from the table is necessary. Tell me how to fix this tpl file so that it is as it should be?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
lnked, 2017-01-09
@lnked

Try this (not tested)

<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6 highheader2">
    <form action="{$rsAuth[0].route}" name="formAuth">
        <select name="auth">
            {foreach $rsAuth as $item name=auth}
            <option value="{$item.name}" onchange="document.forms['formAuth'].action='{$item.route}'">{$item.name}</option>
            {/foreach}
        </select>
    </form>
</div>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question