2009年10月6日星期二

[fw-mvc] Problems using "belongsTo" on an element within a "subform"

Hi all,

I'm trying to build a Zend_Form which is built using quite a few subforms
(ZendXjQuery forms). In only one of these subforms I have some elements
which I would like to have added to an array, and therefore I am using
belongsTo for those elements.

The HTML rendered is perfect for the form and displays exactly I would
imagine with my elements being rendered like <input type="text"
name="my_array-input_name" id="my_array[input_name]" value="0" />. So far so
good.

The problem comes that when I use $form->isValid() in my controller, this
seems to have issues with my arrayed elements. All validation messages are
perfect, all the other form elements are fine...

BUT, say for instance I had inputted "999" as my value in one of the array
fields, when I post the form, if validation is unsuccessful, then although
the other elements in my form remember their posted values, the arrayed
elements all get set to 0.

If I post the form with no validation problems, and use
Zend_Debug::dump($this->_request->getPost()) in my controller, the array
looks the way that I would imagine?! So my guess is that isValid() does not
like the way I have built the form? And example of a successful posted array
is something like:

array(47) {
["submit"] => string(4) "Save"
["request_token"] => string(32) "0b17c812728b415bb51fe1b65f548725"
["first_name"] => string(5) "foo"
["last_name"] => string(5) "bar"
["my_arrayed_element"] => array(10) {
["example_one"] => string(5) "baz"

...
}

This is the array format that I wish to receive the posted variables in,
it's just getting it to stop forgetting the arrayed elements when validation
is not successful.
--
View this message in context: http://www.nabble.com/Problems-using-%22belongsTo%22-on-an-element-within-a-%22subform%22-tp25767284p25767284.html
Sent from the Zend MVC mailing list archive at Nabble.com.

没有评论: