Thanks niphold and thanks for pointing out the missing ()

Simon

On 20 August 2012 21:32, Niphlod <[email protected]> wrote:

> take a look in the book
> http://web2py.com/books/default/chapter/29/7#Hidden-fields.
>
> If you have a page where the post is shown and the comments are "at the
> bottom" (so you have the post_id somewhere in the controller or in the
> request.args or vars) you can still do something like
>
> db.comments.post_id.default = post_id
> db.comments.post_id.readable = db.comments.post_id.writable = False
>
> form = SQLFORM(db.comments)
> ....
>
>
>
> PS: mind the IS_NOT_EMPTY without () for "title" in "comments".
>
>
> On Monday, August 20, 2012 10:23:47 PM UTC+2, Simon Carr wrote:
>>
>> I am still writing my learning application a Blog. I have now created a
>> function in my controller to produce a form for users to leave comments for
>> a post.
>>
>> How do I add a hidden field to the comment form with the post_id? here is
>> my database defs if it helps.
>>
>>
>> db.define_table(
>> 'post',
>> Field('author',db.auth_user),
>> Field('date_created','**datetime',default=request.now)**,
>> Field('title',requires=IS_NOT_**EMPTY()),
>> Field('body','text',requires=**IS_NOT_EMPTY()),
>> format='%(title)s')
>>
>> db.define_table(
>> 'comments',
>> Field('post_id',db.post),
>> Field('author',db.auth_user),
>> Field('date_created','**datetime',default=request.now)**,
>> Field('title',requires=IS_NOT_**EMPTY),
>> Field('comment','text',**requires=IS_NOT_EMPTY()),
>> format='%(title)s')
>>
>>
>>
>> Thanks
>> Simon
>>
>  --
>
>
>
>

-- 



Reply via email to