matkolbe
unread,Jun 21, 2009, 9:07:46 AM6/21/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to web2py Web Framework
Hello there,
I have a problem, validating the form does not react.
The code in the controller inputform is defined global):
inputform=FORM(TABLE(TR(B(T('Date:')),INPUT
(_type="text",_name="new_date",_class="field-width-80 field-padding-
right-10",_id="new_datepicker_id",requires=[IS_NOT_EMPTY(),IS_DATE
(format=T('%Y/%m/%d'))]),_class="tr-height-30"),
TR(B(T('Amount:')),INPUT
(_type="text",_name="new_amount",_id="new_amount_id",requires=
[IS_NOT_EMPTY(), IS_FLOAT_IN_RANGE(0,100000)],_class="field-
width-150"),_class="tr-height-30"),
TR(B(T('Description:')),INPUT
(_type="text",_name="new_description",_id="new_description_id",requires=IS_NOT_EMPTY
(), _class="field-width-150"),_class="tr-height-30"),
TR(T('Comment:'),INPUT(_type="text",_name="new-
comment",_id="new_comment_id",_class="commentfield field-width-150")),
TR("",INPUT(_type="submit",_value=T("Add new
entry")),_class="sendingbutton tr-
height-50")),_formname="form_newflexiblecost",_id="form-
newflexiblecost_id")
and the ajax function:
def insert_flexiblecost():
savesuccess="-1"
if inputform.accepts
(request.vars,session,formname='form_newflexiblecost'):
from applications.haushaltsbuch.modules.custom_timefunctions
import convert_to_timestamp
current_date=convert_to_timestamp
(inputform.vars.new_date_id.year,inputform.vars.new_date_id.month,inputform.vars.new_date_id.day,
0,0,0)
inserted_id=db.flexible_cost.insert
(book_id=session.bookid,description=inputform.vars.new_description_id,amount=inputform.vars.new_amount_id,
\
comment=inputform.vars.new_comment_id,in_date=current_date,timetable_id=session.monthdateid)
if inserted_id>0:
savesuccess="1"
else:
savesuccess="0"
elif inputform.errors:
savesuccess="0"
return savesuccess
I always get -1 returned. It seems like the accepts() is not
registering the form submit. I exactly realized like in the ebook
mentioned...
Has anyone a similar problem?
grettings,
mathew