The only way I make it work is get two forms + one form to get back.
View:
{{extend 'layout.html'}}
{{if session.secao:}}
Seção:     
{{=db.secao[session.secao].nome}}
{{=form_voltar}}
<hr /><br />
{{=form}}
{{else:}}
{{=form_secao}}
{{pass}}
Controller:
def enviar():
form_voltar = FORM(INPUT(_type='submit'))
form_voltar.submit_button="Voltar"
if form_voltar.accepts(request.vars, session):
del session.secao
secao = db(db.secao.site_id==2)
form_secao = SQLFORM.factory(
Field('secao', requires=IS_IN_DB(secao, 'secao.id', '%(nome)s')
),submit_button='Enviar')
if form_secao.accepts(request.vars, session):
response.flash = 'Seção escolhida:'
session.secao = form_secao.vars.secao
#session.filename = form.vars.your_image
elif form_secao.errors:
response.flash = 'form has errors'
return dict(form_secao=form_secao)
db.artigo.situacao.writable=False
db.artigo.situacao.readable=False
db.artigo.secao_id.requires=IS_IN_DB(secao, 'secao.id', '%(nome)s')
db.artigo.secao_id.writable=False
db.artigo.secao_id.readable=False
db.artigo.secao_id.default=session.secao
db.artigo.site_id.default=2
categoria = db(db.categoria.secao_id==session.secao)
db.artigo.categoria_id.requires=IS_IN_DB(categoria, 'categoria.id',
'%(nome)s')
if request.vars:
db.artigo.secao_id.default=session.secao
form= SQLFORM(db.artigo,submit_button='Enviar artigo')
if form.accepts(request.vars, session):
response.flash= T('Seu artigo foi enviado')
return dict(form=form,form_secao=form_secao,form_voltar=form_voltar)
I think it could be improved, but I trying a better way yet.
2009/9/17 mika <[email protected]>
>
> I have the following table:
>
> db.define_table('logicalmachines',
> SQLField('physical_id',db.physicalmachines),
> SQLField
> ('description','string',length=50,unique=True),
> SQLField('description_long', 'string'),
> SQLField('last_audit_date','date'),
> SQLField('os', db.cpe),
> SQLField('dest_type','string',length=100),
> SQLField('reaction_time','string'),
> SQLField('other_software','string',length=500),
> SQLField('other_security','string',length=500))
>
> and I would like to create form which will have combo (i mean html
> SELECT)
> to select machines by description, and after making choice, the whole
> information about machine
> have presented
> (generated by SQLForm?) I tried to find some example how to do it, but
> nothing similar found.
> Could you help me?
>
> Cheers,
> mika
> >
>
--
Atenciosamente
--
=========================
Alexandre Andrade
Hipercenter.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---