Index: library/Zend/Form.php =================================================================== --- library/Zend/Form.php (revision 23576) +++ library/Zend/Form.php (working copy) @@ -1013,6 +1013,7 @@ * @param string|Zend_Form_Element $element * @param string $name * @param array|Zend_Config $options + * @throws Zend_Form_Exception on invalid element * @return Zend_Form */ public function addElement($element, $name = null, $options = null) @@ -1050,6 +1051,9 @@ $this->_elements[$name] = $element; $this->_elements[$name]->addPrefixPaths($prefixPaths); + } else { + require_once 'Zend/Form/Exception.php'; + throw new Zend_Form_Exception('Element must be specified by string or Zend_Form_Element instance'); } $this->_order[$name] = $this->_elements[$name]->getOrder(); Index: tests/Zend/Form/FormTest.php =================================================================== --- tests/Zend/Form/FormTest.php (revision 23576) +++ tests/Zend/Form/FormTest.php (working copy) @@ -4415,6 +4415,16 @@ } $this->assertNotEquals($result,''); } + + /** + * @group ZF-10865 + * @expectedException Zend_Form_Exception + */ + public function testExceptionThrownWhenAddElementsIsGivenNullValue() + { + $form = new Zend_Form(); + $form->addElement(NULL); + } } class Zend_Form_FormTest_DisplayGroup extends Zend_Form_DisplayGroup