Попытка сделать опрос в приложении web2py.
Модель
db.define_table('t_query',
Field('f_content', type='text', requires=IS_NOT_EMPTY(),
label=T('Content')),
SQLField('is_active',db.auth_user,writable=False,readable=False),
auth.signature,
migrate=settings.migrate)
db.define_table('t_option',
Field('f_ocontent', type='string',requires=IS_NOT_EMPTY(),
label=T('Option')),
auth.signature,
migrate=settings.migrate)
Контроллер
def ask():
form=SQLFORM.factory(db.t_query,db.t_option,db.t_option)
if form.process().accepted:
id = db.t_query.insert(**db.t_query._filter_fields(form.vars))
form.vars.client=id
id = db.t_option.insert(**db.t_option._filter_fields(form.vars))
response.flash='Thanks for filling the form'
id = db.t_option.insert(**db.t_option._filter_fields(form.vars))
response.flash='Thanks for the question'
return dict(form=form)
Просмотр
{{extend 'layout.html'}}
<h2>Start a Poll</h2>
{{=form}}
выход
![current](https://i.stack.imgur.com/r9ySR.png)
Я попытался найти способ попросить SQLFORM использовать поля из одной и той же таблицы несколько раз в форме.
Это то, что я ожидаю:
![gexpectation](https://i.stack.imgur.com/So3nO.png)
Как мне это сделать?
Задал тот же вопрос на web2py @ googlegroups https://groups.google.com/forum/#!topic/web2py/48tO5ncC2t4