PHP index page with edit function how to send data for mustache template

27 Views Asked by At

I have an index.php page with direct edit function on it. Each record can be edited through an select option.

I defined a data like this:

    [{"id":20,"selected":2,"scores":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]},
    {"id":22,"selected":8,"scores":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]},
    {"id":24,"selected":10,"scores":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]},
    {"id":26,"selected":false,"scores":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]},
    {"id":28,"selected":15,"scores":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]}]

But i was not able to render the select options correctly, i tried like this:

        <select name="score[{{{id}}}]" id={{id}}>
        {{#score_list}}
            <option value="{{#scores}}{{.}}{{/scores}}" selected="{{selected}}">{{#scores}}{{.}}{{/scores}}</option>
        {{/score_list}} 
    </select>

It renders the select list like this: enter image description here

Instead of separately the array elements its shows all the scores in each line of the select lists .

I run out of the ideas, please help me how to display correctly, thank you in advance

EDIT: I tried the following:

<select name="score[{{{id}}}]" id={{id}}>
        {{#score_list}}
            {{#scores}}
                <option value="{{.}}" {{#selected}}selected{{/selected}}>{{.}}</option>
            {{/scores}} 
        {{/score_list}}

Its display the scores separately the scores but it's display 5 times the 0..15 and does not set the selected value

0

There are 0 best solutions below