我正在尝试将一个字段显示为一个自定义表单中的单选按钮组。我想将每个单选按钮放在表中的不同行上。问题是,当我使用{{=form.custom.selection_type[0]}}
时,小部件被包装在不需要的tr
和td
标记中。有没有办法只添加单选按钮?
我的表单:
{{extend 'layout.html'}}
{{=form.custom.begin}}
<table>
<tr>
<td> {{=form.custom.selection_type[0]}}:</td>
<td> {{=form.custom.widget.biller_list}}</td>
</tr>
<tr>
<td> {{=form.custom.widget.selection_type[1]}}:</td>
<td> {{=form.custom.widget.biller_code}}</td>
</tr>
</table>
{{=form.custom.end}}
html源代码中发生的事情的示例:
<table>
<tr>
<td> <tr><td><input name="selection_type" type="radio" value="From my biller list" />From my biller list</td></tr>:</td>
...
</tr>
...
</table>
我的模型:
db.define_table('payment_bpay_step1',
Field('selection_type', 'list:string'),
Field('biller_list', db.biller, notnull=True),
Field('biller_code'),
Field('biller_name'))
db.payment_bpay_step1.selection_type.requires = IS_IN_SET(('From my biller list', 'Search by biller code', 'Search by biller name'))
db.payment_bpay_step1.selection_type.widget = SQLFORM.widgets.radio.widget
发布于 2011-09-17 20:48:53
它还不是稳定的,但在主干中,你现在可以为广播小部件指定ul或div样式而不是表格样式。我想应该是:
db.payment_bpay_step1.selection_type.widget = \
lambda f, v: SQLFORM.widgets.radio.widget(f, v, style='divs')
您还可以创建自定义小部件,如this section in the book末尾所述。
当您说您希望"innerhtml“不同于单选按钮的值时,您是在谈论单选按钮旁边的标签吗?为此,标签验证器接受一个‘IS_IN_SET’参数,该参数是与集合中的选项相关联的标签列表。
https://stackoverflow.com/questions/7456050
复制