This question has been flagged
1 Reply
9968 Views

Below code only shows what I have selected in the backend. It doesn't show other values. I know below code only show current value. But I want to get all the selected field values. Any suggestions?

<label class="control-label" for="web_priority">Priority</label>

              <select name="web_priority" class="form-control">

        <t t-foreach="order or []" t-as="a">

            <option t-att-value="web_priority"  selected="True"> <t t-esc="order.web_priority" />

            </option>

        </t>

    </select>

Avatar
Discard
Author

Hello Niyas, Checkout that link, Me too answered that. What I am asking is How to show selection field values Like Many2one.

Best Answer


Use <select> to show the Selection field in website form.

your_field = fields.Selection([('10', '10'), ('20', '20'), ('30', '30'), ('40', '40')])
 
    .........
        <select>
            <option value="10">10</option>
            <option value="20">20</option>
            <option value="30">30</option>
            <option value="40">40/option>

                 .......
        </select>         
    .........
 

 


Avatar
Discard
Author

What I am asking is How to show selection field values Like Many2one. Just like list of countries in website template. Countries are many2one but my fields are defined in fields.Selection.

thanks,
but i have a question.
how can I option default selected from DB, for example 'your_field' = 30 in DB and I want show in frontend web from as default value.
I use like below but dont answer:

<select>
<option value="10" t-att-selected="[('your_filed','=',10)]">10</option>
<option value="20" t-att-selected="[('your_filed','=',20)]">20</option>
<option value="30" t-att-selected="[('your_filed','=',30)]">30</option>
<option value="40" t-att-selected="[('your_filed','=',40)]">40/option>
.......
</select>

do you have a idea??