1) Post created in a particular category. -
http://hostname/app/default/created_ad/<category>
2)The category tied subcategories.
How to make that SQLFORM display only radio button of equal sub categories. Not show subcategories not belong to this category.
![](https://lh6.googleusercontent.com/-1fPHpZIZWus/U7Un7A7o-7I/AAAAAAAAGUM/ARW_lvfxgyw/s1600/web2py.png)
def get_category():
category_url_name = request.args(0)
category = db.category(url_name=category_url_name)
if not category:
session.flash = 'page not fount'
redirect(URL('index'))
return category
def created_ad():
category = get_category()
form = SQLFORM(db.ad_post).process(next='view_post/[id]')
return locals()
db.define_table('ad_post',
Field('category', 'reference category'),
Field('subcategory', 'reference subcategory', widget=SQLFORM.widgets.radio.widget,
Field('title', type='string', requires=IS_NOT_EMPTY()),
Field('body', type='text', requires=IS_NOT_EMPTY()),
auth.signature
)