[web2py] How to choose a subcategory to create a post

2014-07-03 Thread Капылов Данил
1) Post created in a particular category. - 
http://hostname/app/default/created_ad/

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.




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()
db.ad_post.category.default = category.id
   * 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,*
*  requires=IS_IN_DB(db, db.subcategory.id, 
label='db.category.name')),*
Field('title', type='string', requires=IS_NOT_EMPTY()),
Field('body', type='text', requires=IS_NOT_EMPTY()),
auth.signature
)

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] How to choose a subcategory to create a post

2014-07-04 Thread Fabiano Almeida
Can you try use plugin:
http://dev.s-cubism.com/plugin_lazy_options_widget


2014-07-03 6:53 GMT-03:00 Капылов Данил :

> 1) Post created in a particular category. -
> http://hostname/app/default/created_ad/
>
> 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.
>
>
> 
>
>
> 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()
> db.ad_post.category.default = category.id
>* 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,*
> *  requires=IS_IN_DB(db, db.subcategory.id
> , label='db.category.name
> ')),*
> Field('title', type='string', requires=IS_NOT_EMPTY()),
> Field('body', type='text', requires=IS_NOT_EMPTY()),
> auth.signature
> )
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.