Zend Framework - 使用javascript添加新的输入元素 [英] Zend Framework - Add new input element using javascript

查看:162
本文介绍了Zend Framework - 使用javascript添加新的输入元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Zend Framework开发项目。

I'm working on a project using Zend Framework.

我正在创建一个表单,用户可以通过按+符号添加一组元素。

I'm creating a form on which users can add a set of elements by pressing a + sign.

Zend框架使用子表单和装饰器从表单中获取值数组。

Zend framework uses subforms and decorators to get array of values from a form.

这些将显示何时页面显示

These will show when the page is displayed

使用Javascript创建的新字段如何集成在该模型中?

How does the new fields created with Javascript integrate in that model?

推荐答案

将客户端上的字段动态添加到我熟悉的 Zend_Form 的最佳演示来自Jeremy Kendall:

The best demo of dynamically adding fields on the client to a Zend_Form with which I am familiar comes from Jeremy Kendall:

http:// jeremykendall.net/2009/01/19/dynamically-adding-elements-to-zend-form/

该技术的结果是添加/在表单上调用 preValidation()方法来检查表单中缺少字段的帖子。如果找到任何此类字段,则将它们添加到表单对象中。当 isValid() getValues()被调用时,所有 Zend_Form_Element 对象已经附加到表单,因此处理正常运行。

The upshot of the technique is to add/call a preValidation() method on the form to check the post for fields missing in the form. If it finds any such fields, then they are added to the form object. By the time isValid() and getValues() are called, all the Zend_Form_Element objects have already been attached to the form, so processing runs as normal.

这篇关于Zend Framework - 使用javascript添加新的输入元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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