I think you are missing .process()
form = SQLFORM(db.comment_post, r).process()
On Sunday, 18 January 2015 22:58:55 UTC-6, M.C. Botha wrote:
>
> I would like to use a bootstrap modal to create new and update existing
> records using a bootstap modal.
> It works for new records but I cannot get it to work for updating existing
> ones and thus not to delete either.
>
> What am I doing wrong in the post.load views and in the
> comments.py.get_comment code?
>
> Can someone please help?
>
> *models/tables.py*
>
> db.define_table('comment_post',
> Field('title','string',label='Comment title', requires=IS_NOT_EMPTY()),
> Field('body','text',label='Your comment', requires=IS_NOT_EMPTY()),
> auth.signature)
>
>
>
> *controllers/default.py*
>
> def index():
> return dict()
>
>
>
> *views/default/index.html*
>
> {{extend 'layout.html'}}
> <h3>Comments</h3>
> {{=LOAD('comments','post.load',ajax=True)}}
>
>
>
> *controllers/comments.py*
>
> @auth.requires_login()def post():
> return dict(form=SQLFORM(db.comment_post,
> formstyle='bootstrap3_stacked').process(),
>
> comments=db(db.comment_post).select(orderby=~db.comment_post.id, limitby=(0,
> 3)))
> @auth.requires_login()def get_comment():
> r = db.auth_user(request.vars.id) or redirect(URL('index'))
> form = SQLFORM(db.comment_post, r)
> return form
>
>
>
> *views/comments/post.load*
>
> {{for post in comments:}}
> <div class="post">{{=post.title}}: on <small>{{=post.created_on}}</small>
> {{=post.created_by.first_name}}
> <small>said:</small> "<span class="post_body">{{=post.body}}</span>"
> {{=A('Edit', callback=URL('welcome', 'comments', 'get_comment',
> vars={'id': post.id}), target="form_load")}}
> </div>
> {{pass}}
> <hr>
> <button type="button" class="btn btn-primary btn-lg" data-toggle="modal"
> data-target="#myModal">
> Launch demo modal</button>
> <!-- Modal --><div class="modal fade" id="myModal" tabindex="-1"
> role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
> <div class="modal-dialog">
> <div class="modal-content">
> <div class="modal-header">
> <button type="button" class="close" data-dismiss="modal"
> aria-label="Close"><span aria-hidden="true">×</span></button>
> <h4 class="modal-title" id="myModalLabel">Modal title</h4>
> </div>
> <div id="form_load" class="modal-body">
> {{=form}}
> </div>
> <div class="modal-footer">
> <button type="button" class="btn btn-default"
> data-dismiss="modal">Close</button>
> </div>
> </div>
> </div></div>
>
>
>
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.