A better solution:

in forms.py:

def getPostForm():
    category_list = model.get_categories()
    category_options = [(row.id, row.description) for row in
category_list]
    post_form = form.Form(
        form.Textbox('title', form.notnull, size=30, description="Post
title:"),
        form.Dropdown('category', category_options),
        form.Textarea('content', form.notnull, rows=30, cols=80,
description="Post content:"),
        form.Button('Post entry'),
    )
    return post_form

in code.py:

class NewPost:

    def GET(self):
        form = forms.getPostForm()
        return render.new(form)

    def POST(self):
        form = forms.getPostForm()
        if not form.validates():
            return render.new(form)
        model.new_post(form.d.title, form.d.content, form.d.category)
        raise web.seeother('/')

Thanks friends for all help.

best regards,
Leandro.

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" 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/webpy?hl=en.

Reply via email to