title: Zend_Form_Element fails when i addElements
body: <p>I have been having trouble adding a hidden zend form element.</p>
  
  <p>when i invoke addElements the form fails and prints the following error to the page.
  but only when i try and add $formContactID and $formCustomerID.</p>
  
  <blockquote>
    <p>Fatal error: Call to a member function getOrder() on a non-object in /home/coder123/public_html/wms2/library/Zend/Form.php on line 3291</p>
  </blockquote>
  
  <p>My code is as follows.</p>
  
  <pre><code>  private function buildForm()
   {
    $Description = "";
    $FirstName = "";
    $LastName = "";
    $ContactNumber = "";
    $Fax = "";
    $Position = "";
    $Default = "";
    $custAddressID = "";
    $CustomerID = "";
    $Email = "";
    $ContactID = "";
    if($this-&gt;contactDetails != null)
    {
     $Description = $this-&gt;contactDetails['Description'];
     $CustomerID = $this-&gt;contactDetails['CustomerID'];
     $FirstName = $this-&gt;contactDetails['FirstName'];
     $LastName = $this-&gt;contactDetails['LastName'];
     $ContactNumber = $this-&gt;contactDetails['ContactNumber'];
     $Position = $this-&gt;contactDetails['Position'];
     $Fax = $this-&gt;contactDetails['Fax'];
     $Email = $this-&gt;contactDetails['Email'];
     $Default = $this-&gt;contactDetails['Default'];
     $custAddressID = $this-&gt;contactDetails['custAddressID'];
     $ContactID = $this-&gt;contactDetails['custContactID'];
    }
  
  
    $formfirstname = new Zend_Form_Element_Text('FirstName');
    $formfirstname-&gt;setValue($FirstName)-&gt;setLabel('First Name:')-&gt;setRequired();
  
    $formlastname = new Zend_Form_Element_Text('LastName');
    $formlastname-&gt;setLabel('Last Name:')-&gt;setValue($LastName)-&gt;setRequired();
  
    $formPhone = new Zend_Form_Element_Text('ContactNumber');
    $formPhone-&gt;setLabel('Phone Number:')-&gt;setValue($ContactNumber)-&gt;setRequired();
  
    $formFax = new Zend_Form_Element_Text('FaxNumber');
    $formFax-&gt;setLabel('Fax Number:')-&gt;setValue($Fax);
  
    $FormPosition = new Zend_Form_Element_Text('Position');
    $FormPosition-&gt;setLabel('Contacts Position:')-&gt;setValue($Position);
  
    $FormDescription = new Zend_Form_Element_Text('Description');
    $FormDescription-&gt;setLabel('Short Description:')-&gt;setValue($Description)-&gt;setRequired();
  
    $formEmail = new Zend_Form_Element_Text('Email');
    $formEmail-&gt;setLabel('Email Address:')-&gt;setValue($Email);
  
    $FormDefault = new Zend_Form_Element_Checkbox('Default');
    $FormDefault-&gt;setValue('Default')-&gt;setLabel('Set as defualt contact for this business:');
  
    if($Default == 'Default')
    {
     $FormDefault-&gt;setChecked(true);
    }
  
    $formCustomerID = new Zend_Form_Element_Hidden('customerID');
    $formCustomerID-&gt;setValue($customerID);
    if($this-&gt;contactID != null)
    {
     $formContactID = new Zend_Form_Element_Hidden('ContactID');
     $formContactID-&gt;setValue($this-&gt;contactID);
    }
  
  // FORM SELECT 
    $formSelectAddress = new Zend_Form_Element_Select('custAddress');
    $pos = 0;
    while($pos &lt; count($this-&gt;customerAddressArray))
    {
     $formSelectAddress-&gt;addMultiOption($this-&gt;customerAddressArray[$pos]['custAddressID'], $this-&gt;customerAddressArray[$pos]['Description']);
     $pos++;
    }
    $formSelectAddress-&gt;setValue(array($this-&gt;contactDetails['custAddressID']));
    $formSelectAddress-&gt;setRequired()-&gt;setLabel('Default Address For this Contact:');
  // END FORM SELECT
  
    $this-&gt;setMethod('post');
    $this-&gt;setName('FormCustomerEdit');
  
    $formSubmit = new Zend_Form_Element_Submit('ContactSubmit');
    $formSubmit-&gt;setLabel('Save Contact');
  
    $this-&gt;setName('CustomerContactForm');
    $this-&gt;setMethod('post');
  
  
    $this-&gt;addElements(array($FormDescription, $formfirstname, $formlastname, 
           $FormPosition, $formPhone, $formFax, $FormDefault, 
           $formEmail, $formSelectAddress, $formContactID, $formCustomerID, $formSubmit));
  
    $this-&gt;addElements(array($formSubmit));
  
   }
  </code></pre>