如何使用TALES表达式在PloneFormGen中生成注册号? [英] How can I generate a registration number in PloneFormGen, using a TALES Expression?

查看:113
本文介绍了如何使用TALES表达式在PloneFormGen中生成注册号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用PloneFormGen为会议设置注册表,我想使用TALES表达式计算现有记录的数量,添加"1",然后在谢谢"页面上显示作为注册人的注册号.这可能吗?

I am trying to set up a registration form for a conference using PloneFormGen, and I would like to use a TALES Expression to count the number of existing records, add "1", then display this on the "Thank You" page as the registrant's registration number. Is this possible?

我过去曾使用以下代码生成一个随机的6位数字,以为支持请求创建案例号ID,该数字除了跟踪请求外没有其他关系,一旦结案了.

I have used the following to generate a random 6 digit number in the past to create a case number ID for a support request, where the number didn't matter other than to track the request, then it would be deleted once the case is closed.

python:random.randint(100000, 999999)

我是在正确的轨道上吗,还是我完全以错误的方式来做这件事?

Am I on the right track, or am I going about this completely the wrong way?

推荐答案

我过去使用以下技巧来做到这一点:

I've done this in the past with the following trick:

  1. 在ZMI中,我在表单上创建一个名为"reg_count"的整数属性,其中包含起始编号(导航到表单文件夹,并将/manage_propertiesForm附加到URL);

  1. In the ZMI, I create on the form an integer property named "reg_count" containing the starting number (navigate to the form folder and append /manage_propertiesForm to the URL);

向表单添加一个隐藏字段.我用了id"regno";

Add a hidden field to the form. I used the id "regno";

使用自定义脚本适配器来获取reg_count属性,对其进行递增,然后将其放入请求的表单字典中:

Use a custom script adapter to fetch the reg_count property, increment it, and put it in the request's form dictionary:

reg_count = context.getProperty('reg_count', 0) + 1
context.manage_changeProperties(reg_count=reg_count)
request.form['regno'] = str(reg_count)

  • 自定义感谢页面以显示它.

  • Customize the thanks page to display it.

    这篇关于如何使用TALES表达式在PloneFormGen中生成注册号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆