Right off the bat, my total exposure to Turbogears has been about 30
minutes (including watching the webcast ;). I've used Python for a few
years now, but I seem to be overwhelmed with Turbogears and I'm really
grappling with what should be something simple.
I'm a little (lot) stumped on how to have a validator on a single input
inside of a RemoteForm. What I'm having a problem with, is when the
form is submitted with nothing in the input field, I want the validator
to prompt that entry is required. However what happens is that the
entire form is repeated in the "results" div.
I'm trying to follow some sample code I found through Google, and the
FormsTemplate sample code from the Trac entry SimpleWdgetForm. The Trac
entry for RemoteForm consists simply of "ghjghjgjfgjgh" so it wasn't
much help either.
I see that RemoteForm has an update option, which is where the output
naturally will be written so (so I guess), however that's also where
the validator code is written to. I'm confused on how to have the
validator message "stay" with the form, and not re-write the form in
the results div.
Any help would be appreciated.
Here are some snippets from my (bad) code:
controller.py:
------------------
class FindTicketField(widgets.WidgetsList):
ticketNum = widgets.TextField(validator=validators.NotEmpty)
fticket_form = widgets.RemoteForm(
name = "findIt",
fields = FindTicketField(),
update = "results",
submit_text = "Find",
action = "tickSearch")
@expose(template="slwork.templates.findticket")
def findticket(self, tg_errors=None):
if tg_errors:
flash('Please fill out the form...')
return dict(form=fticket_form)
@expose()
@validate(form=fticket_form)
@error_handler(findticket)
def tickSearch(self, ticketNum):
ticks = model.FPTicket.selectBy(id = ticketNum)
return dict(ticks=ticks)
templates.findticket:
-----------------------------
<p py:content="form.display()"></p>
<div id="results"></div>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---