将变量从 Zend 控制器传递到 Zend 表单 [英] Pass a variable from Zend controller to zend form
本文介绍了将变量从 Zend 控制器传递到 Zend 表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将一个变量从控制器传递到表单.如何实施?任何人都可以帮助我解决这个问题.
I wanted to pass a variable from a controller to the form. How can this be implemented? Can anyone please help me on this issue.
谢谢.
推荐答案
在您的应用程序的控制器方法中.addMultiOptions($options);
In the controller method of your application. addMultiOptions($options);
class OrderController extends Zend_Controller_Action
{
$options = array(
'foo' => 'Foo2 Option',
'bar' => 'Bar2 Option',
'baz' => 'Baz2 Option',
'bat' => 'Bat2 Option'
);
$form = new Application_Form_PlaceNewOrder();
$form->items->addMultiOptions($options);
....
}
在您的应用程序的表单脚本中.
In the form script of your application.
class Application_Form_PlaceNewOrder extends Zend_Form
{
public function init()
{
$items= new Zend_Form_Element_Select('items');
$items->setLabel('Items: *');
$items->setValue('foo');
....
}
这篇关于将变量从 Zend 控制器传递到 Zend 表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文