Hi all,
I used mako for template engine in my app, and I faced a problem of
form error rendering. I used individual field rendering, and it can't
show any form error message. Here's my handler codes:
def POST(self, slug):
f = commentForm()
d['entry'], d['p'] = self.getEntry(slug)
if f.validates():
db.insert('comments',
createdTime=datetime.now().strftime("%Y-%m-%d %H:
%M"),
entryId=d['entry'].entryId, **f.d)
db.update('entries',
where="id=%s" % d['entry'].entryId,
commentNum=int(d['entry'].commentNum)+1)
raise web.seeother('/entry/%s/' % slug)
else:
d['f'] = f
d['usedTime'] = time.time() - d['startTime']
return render.entry(**d)
and here's the template codes:
<form action="/entry/${ entry.entry_slug }/"
method="POST">
<table>
<tr>
<th>昵称(*)</th>
<td>${ f.username.render() }</td>
</tr>
<tr>
<th>Email地址(*)</th>
<td>${ f.email.render() }</td>
</tr>
<tr>
<th>个人网站</th>
<td>${ f.url.render() }</td>
</tr>
<tr>
<th>留言内容(*)</th>
<td>${ f.comment.render() }</td>
</tr>
<tr>
<th> </th>
<td><input type="submit" value="发表留言"
style="width:auto;" /></td>
</tr>
</table>
</form>
when I submited an empty form or made some field error, it can't show
any error message. so wired. When I changed f.xxx.render() to f.render
() in template, it can show error message, I don't know why.
Any ideas?
--
You received this message because you are subscribed to the Google Groups
"web.py" 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/webpy?hl=en.