3

Im currently creating a zend form status dropdown to let users to update their status.

All the status values are coming from the the database. Using the getProviderQuoteStatus($providerId,$quoteId,$quoteStatusId) method to determine what status is available to the user.

The problem I'm facing at the moment is when the form go through the validation process.

I'm keep getting '1' was not found in the haystack (because the status values is populated in the controller and not in the form itself therefore the providerQuoteStatus form element array is empty) . Can anyone help me out how can I solve this problem?

Thanks so much in advance!

  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);

            }
    }

1 Answer 1

7

Taken from the Zend Website:

By default, this element registers an InArray validator which validates against the array keys of registered options. You can disable this behavior by either calling setRegisterInArrayValidator(false), or by passing a FALSE value to the registerInArrayValidator configuration key.

I have had this problem before and disabling this default validator does the trick.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks so much! Work perfectly now :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.