I changed the previous model a little:
MODEL:
db.define_table('erro_impressora',
                          Field('descricao','string'),
                          Field('nivel', 'integer' )
)



Controllers:

def teste():
    rows = db(db.erro_impressora).select()
    return dict(rows=rows)

def update_nivel():
    for key, value in request.post_vars:
        try:
            db.erro_impressora[key].update_record(nivel=value)
        except:
            pass
    db.commit()
    
    redirect(URL('teste'))


VIEW:
{{extend 'layout.html'}}

<form action="{{=URL('update_nivel')}}" method="POST">
    <table>
    {{for row in rows:}}
        <tr><td>{{=row.descricao}}</td><td>{{= SELECT(0,1, value=row.nivel 
) }}
    {{pass}}
    <tr><td colspan='2'>{{=INPUT(_type='submit') }}</td></tr>
    </table>
</form>

I`ve done what you suggested but i couldn`t put it to update. action 
update_nivel() is receiving a empty request.post_vars

Em quarta-feira, 22 de agosto de 2012 15h36min52s UTC-3, rochacbruno 
escreveu:
>
> You can try something like this:
>
> def test():
>     rows = db(db.test).select()
>     return dict(rows=rows)
>
> def update_level():
>     for key, value in request.post_vars:
>         try:        
>             db.table[key].update_record(level=value)
>         except:
>             # do something if key is invalid.
>     db.commit()
>     redirect("URL TO REDIRECT AFTER UPDATES")  # or use ajax
>
> Now in views/controller/test.html
>
> <form action="{{=URL("update_level")}}" method="POST">
>    <table>   
>    {{for row in rows:}}
>    <tr> <td>{{=row.name}}</td><td> *<input type="text" value="" id="{{=
> row.id}}" name="{{=row.id}}" />*</td></tr>       
>    {{pass}}
>    </table>
> </form>
>
>
> On Wed, Aug 22, 2012 at 3:16 PM, Fabiano Faver <far...@gmail.com<javascript:>
> > wrote:
>
>> |     name      |          level          |
>> ----------------------------------
>>       test 1      |    combobox(0)   |
>>       test 2      |    combobox(1)   | 
>>       test 3      |    combobox(0)   |
>>              ________
>>              |  Submit  |
>>              ------------- 
>>
>
>

-- 



Reply via email to