根据当前值有条件地设置 Zend Form 选择元素多选项

发布于 2024-10-25 05:25:28 字数 1145 浏览 4 评论 0原文

目前我正在尝试在 Zend 框架中构建一个 Web 应用程序。

但我不知道如何管理系统中的状态,

例如,我在系统中的报价处理有以下状态

Awaiting for Confirmation
Asssigned
In Progress
Completed
Mark As Spam

,我将这些值存储在名为 ProviderQuoteStatus 的表中,并在 zend_db 类中创建了一个名为 ProviderQuoteStatus() 的函数,使用该函数在 zend 表单下拉框中生成状态值。

   $select = $this->select()->from("providerQuoteStatus",
            array('key' => 'providerQuoteStatusId',
                'value' => 'providerQuoteStatusName'));

   $result = $this->fetchAll($select);

return $result->toArray();

这是我的 Zend 表单代码,

 $serviceType = new Application_Model_DbTable_ProviderQuoteStatus();

 $serviceTypeValues = $serviceType->getProviderQuoteStatusFormValues();

 $dropDownElement = new Zend_Form_Element_Select('providerQuoteStatus');

 $dropDownElement->addMultiOptions($serviceTypeValues);

到目前为止一切正常。如果分配阶段中的报价我只希望提供商选择以下选项

Asssigned
In Progress
Completed

如何删除 Zend 表单下拉框中的“等待确认”和“标记为垃圾邮件”值?

另外,我应该在哪里存储所有这些业务逻辑(例如,如果“已分配阶段”中的报价只能具有“已分配”、“进行中”选项等)?在模型数据库类中?

预先非常感谢:D

Currently I'm trying to build a web application in Zend framework.

But I can't figure out how to Manage status in my system

Eg I have the following status for my quote handling in the system

Awaiting for Confirmation
Asssigned
In Progress
Completed
Mark As Spam

I stored these values in a table called ProviderQuoteStatus and I created a function called ProviderQuoteStatus() in the zend_db class and uses the function to generate status values in zend form dropdown box.

   $select = $this->select()->from("providerQuoteStatus",
            array('key' => 'providerQuoteStatusId',
                'value' => 'providerQuoteStatusName'));

   $result = $this->fetchAll($select);

return $result->toArray();

Here is my Zend form code

 $serviceType = new Application_Model_DbTable_ProviderQuoteStatus();

 $serviceTypeValues = $serviceType->getProviderQuoteStatusFormValues();

 $dropDownElement = new Zend_Form_Element_Select('providerQuoteStatus');

 $dropDownElement->addMultiOptions($serviceTypeValues);

Everything working fine till this stage. If the quote in Asssigned Stage I only wanted the provider select these following options

Asssigned
In Progress
Completed

How can I remove 'Awaiting for Confirmation' and 'Mark As Spam' values in the Zend form dropdown box ?

Also where should I stored all these business logic (For example if the quote in Assigned Stage only can have Assigned, In Progress options etc)? In the Model DB class?

Thanks so much in advance :D

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

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

发布评论

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

评论(1

荭秂 2024-11-01 05:25:28

您可以像您所做的那样,使用 $form-init() 中的所有可能选项填充 select 元素。但随后在 $form->setDefaults($defaults) 期间修改元素,此时您将知道元素的当前值并确定哪些选项不再合适:如果元素值是“已分配”,然后删除“等待”和“垃圾邮件”选项。

You could populate the select element with all the possible options in $form-init(), as you are doing. But then modify the element during $form->setDefaults($defaults), at which point you will know the current value of the element and determine which options are no longer appropriate: if the element value is "Assigned", then remove the "Awaiting" and "Spam" options.

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