Hi all,
I've just recently started using widgets and I'm trying to customize some of
my forms.
Following the examples in Rapid Web Applications I successfully got the
following to work:
In my controllers.py:
class ReportFields(widgets.WidgetsList):
ReportTitle = widgets.TextField(label="Report Title",validator=
validators.NotEmpty())
MinimumFollowUpCheck = widgets.CheckBox()
MinimumFollowUpValue = widgets.TextField(validator=validators.Int())
DoseRangeCheck = widgets.CheckBox()
DoseRangeLow = widgets.TextField(validator=validators.Int)
DoseRangeHigh = widgets.TextField(validator=validators.Int)
report_form = widgets.TableForm(fields=ReportFields(), submit_text="Create
Report")
@expose(template='lungrx.templates.reportForm')
def createReport2(self,param1,tg_errors=None):
.
.
.
submit_action="/generateReport/"
return dict(form=report_form,values=values,action=submit_action)
In my lungrx.templates.reportForm:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://purl.org/kid/ns#
"
py:extends="'master.kid'">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"
py:replace="''"/>
<title>Report</title>
</head>
<body>
${form(value=values,action=action)}
</body>
</html>
All of this worked beautifully, the right functions were being called and
reports were being created. The layout, however, left a little something to
be desired. In Chapter 16 of the book it outlines a method to control the
layout. This is what I have right now:
controllers.py:
class ReportForm(widgets.Form):
template = "lungrx.templates.reportFormLayout"
fields = [widgets.TextField(name="ReportTitle",label="Report
Title",validator=validators.NotEmpty()),
widgets.CheckBox(name="MinimumFollowUpCheck"),
widgets.TextField(name="MinimumFollowUpValue",validator=
validators.Int(),attrs={'size':5}),
widgets.CheckBox(name="DoseRangeCheck"),
widgets.TextField(name="DoseRangeLow",validator=validators.Int
(),attrs={'size':5}),
widgets.TextField(name="DoseRangeHigh",validator=
validators.Int(),attrs={'size':5})
]
report_form = ReportForm()
lungrx.templates.reportFormLayout:
<form xmlns:py="http://purl.org/kid/ns$"
name="${name}"
actions="${action}"
method="${method}"
py:attrs="form_attrs">
Report Title ${display_field_for("ReportTitle")}<br/>
${display_field_for("MinimumFollowUpCheck")} Minimum follow up time in
months ${display_field_for("MinimumFollowUpValue")}<br/>
${display_field_for("DoseRangeCheck")}Dose Range
${display_field_for("DoseRangeLow")} to
${display_field_for("DoseRangeHigh")}<br/>
</form>
The problem is that the submit button isn't created. I've tried various
methods to add it:
* I've added the line submit_text="Create Report" to the bottom of
ReportForm declaration.
* I added submit_text to the report_form call: report_form =
ReportForm(submit_text="Create Report")
Neither of these methods created the button. I thought to add it to my
template:
<input type="submit" value="Create Report"/>
And while it does create the button when I click on the button it the form
calls itself instead of my generateReport function, ie: instead of
http://localhost:8080/generateReport it calls
http://localhost:8080/createReport2/test2 (test2 being the name of the
report)
I can print out the action being passed to the template and it does say
"/generateReport/" .
Any help would be appreciated.
jason
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" 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/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---