I'll try to be as clear as possible. I'm using a zend form with a text element which is using ->setIsArray(true);
$submenu2 = new Zend_Form_Element_Text('submenu2');
$submenu2->setValue('Sous menu 2')
->setIsArray(true)
->setAttrib('class', 'cloneSub')
->setAttrib('id', 'sub1')
->setAttrib('onFocus', 'javascript:myFocus(this); return;')
->setAttrib('onBlur', 'javascript:myBlur(this); return;');
$this->addElement($submenu2);
I set the element as array because i'm using javascript to dynamically add new elements.
In html, it means :
<input type="text" name="submenu2[]" />
My problem : When i submit the form it generate me the following error
Warning: htmlspecialchars() expects parameter 1 to be string, array given in /usr/local/zend/share/ZendFramework/library/Zend/View/Abstract.php on line 905
After looking everywhere on the web i found the reason but not the solution. It's due to the _escape() method using by zend_form::isValid() which is only expecting strings.
I found a beginning of solution in the Rob Allen's DevNotes here :
http://akrabat.com/page/29/?flattrss_redirect&id=31&md5=b369e042145cc83b1dd4b0031132b801
look at the section : "Simple Zend_Form File Upload Example Revisited"
But when i try to bend the code to resolve my problem, it generates me the following error :
Fatal error: Class 'App_Form_Element_Text' not found in ...
By the way, i encounter the same problem if simply try to populate datas into the same kind of field.
Does anyone has any idea ? Thanks a lot.
UPDATE:
$submenu2 = new Custom_Elements_ArrayElement('submenu2');
$submenu2->setValue('Sous menu 2')
->setIsArray(true)
->setAttrib('class', 'cloneSub')
->setAttrib('id', 'sub1')
->setAttrib('onFocus', 'javascript:myFocus(this); return;')
->setAttrib('onBlur', 'javascript:myBlur(this); return;');
$this->addElement($submenu2);
I created the Class you gave me in "APPLICATION_PATH "/../library/Custom/Elements"
And i get :
Fatal error: Class 'Custom_Elements_ArrayElement' not found