Zend Form 中的 URL 助手的等效项

发布于 2025-01-03 05:02:35 字数 156 浏览 2 评论 0原文

我有一个 zend 表单,我需要在表单上提供动态链接。 IE。用户尝试从下拉菜单中选择 ->如果所需的选项不存在,请单击相邻的链接打开另一个表单,他们可以在其中添加选项。该链接将是动态的,因为我想使用 GET 从当前表单发布一些数据(例如,已选择的国家和地区)。

我该怎么做?

I have a zend form, and I need to provide a dynamic link on the form. ie. user tries to select from drop-down -> if desired option not present, click on the adjacent link to open another form where they can add the option. The link will be dynamic because I want to post some data from the current form using GET (the country and region already selected for example).

How can I do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

初心 2025-01-10 05:02:35
Zend_Controller_Front::getInstance()->getRouter()->assemble($urlOptions, $name, $reset, $encode)

IE:

Zend_Controller_Front::getInstance()->getRouter()->assemble(array('controller' => 'index', 'action' => 'index'), null, true)

与 Zend_View_Helper_Url 中的相同...

Zend_Controller_Front::getInstance()->getRouter()->assemble($urlOptions, $name, $reset, $encode)

IE:

Zend_Controller_Front::getInstance()->getRouter()->assemble(array('controller' => 'index', 'action' => 'index'), null, true)

Same as in the Zend_View_Helper_Url...

吝吻 2025-01-10 05:02:35

您可以使用 javascript/AJAX 在客户端执行此操作 - 检测链接上的点击,收集表单数据并继续到不同的页面。如果您需要其他页面的精美 URL,则必须对服务器进行 AJAX 调用以根据表单参数获取精美 URL,

或者

使链接实际上成为提交按钮,在服务器端处理表单(检测到单击了特殊提交按钮;示例 此处)并重定向到您的其他页面。

至于渲染 Zend_Form_Element 旁边的链接,您可以通过几种方式来实现,其中之一是将其放置在标签或描述中(setLabel()setDescription()< /code>),同时确保将装饰器的 escape 参数设置为 false (示例 此处

You could do this client-side using javascript/AJAX - detect clicking on the link, collect form data and continue to a different page. If you need a fancy URL of the other page, you'd have to make an AJAX call to the server to get the fancy URL based on the form parameters,

or

make the link a submit button actually, process the form server-side (detecting that the special submit button was clicked; example here) and do a redirect to your other page.

As for rendering the link next to a Zend_Form_Element, you can do this in a few ways, one of them would be placing it in the label or description (setLabel(), setDescription()) while making sure to set the escape parameter of the decorator to false (example here)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文