3
我目前正在創建一個zend表單狀態下拉列表讓用戶更新他們的狀態。需要幫助Zend表格
所有狀態值都來自數據庫。 使用getProviderQuoteStatus($ providerId,$ quoteId,$ quoteStatusId)方法確定用戶可以使用的狀態。
我現在面臨的問題是當表單經過驗證過程。
我一直在收到'1' was not found in the haystack
(因爲狀態值在控制器中填充,而不是在窗體本身中,因此providerQuoteStatus表單元素數組爲空)。任何人都可以幫我解決這個問題嗎?
非常感謝!
private function getProviderQuoteStatusForm()
{
$form = new Application_Form_ProviderQuoteStatus(array(
'action' => '/leads/update-Provider-Quote-Status'
,'method' => 'post',
));
return $form;
}
private function getProviderQuoteStatus($providerId,$quoteId,$quoteStatusId)
{
$form = $this->getProviderQuoteStatusForm();
$providerQuoteStatus = new Application_Model_DbTable_ProviderQuoteStatus();
$providerQuoteStatusValues = $providerQuoteStatus->
getProviderQuoteStatusUpdateValues ($quoteStatusId);
$form->getElement('providerQuoteStatus')->addMultiOptions($providerQuoteStatusValues);
$form->getElement('providerQuoteStatus')->setValue($quoteStatusId);
$form->getElement('quoteId')->setValue($quoteId); // set Quote Id to the hidden field
return $form;
}
public function updateProviderQuoteStatusAction()
{
$form = $this->getProviderQuoteStatusForm(); // Status Update dropdown box
$this->view->form = $form;
if ($this->getRequest()->isPost())
{ // is post type request has been made
$formData = $this->getRequest()->getPost();
if ($form->isValid($formData))
{ // form elements has been validated
$quoteId = $form->getValue('quoteId');
$providerQuoteStatus = $form->getValue('providerQuoteStatus');
$this->_helper->redirector('lead'); // redirect back
// $this->_forward('leads');
}
$form->populate($formData);
}
}
非常感謝!現在完美工作:) – user648198 2011-03-28 15:07:58