views:

432

answers:

0

I am building an application with a fairly hefty form that is built using 11 sub-forms (and I will mention that they are all ZendX_jQuery forms).

In one of the sub-forms I have a few quirkier elements. I need a list of features about rooms in a house. So I require multiple text input boxes that belong to an array - these inputs are then added to a fieldset. So for example, this could be about a bathroom and how many toothbrushes, how many bars of soap etc are in there. So the code I have is as follows:

class My_Form extends My_Extended_Form
{

    public function init()
    {

        ...

        // $bathroom_options is an array of options pulled from the database
        foreach ($bathroom_options as $key => $value) {
            $this->addElement('text', $key, array(
               'label'             => $value . ':',
               'required'          => false,
               'belongsTo'         => 'bathroomInfo',
               'maxlength'         => 2,
               'class'             => 'number-input',
               'filters'           => array('Int'),
               'decorators'    => array(
                   'ViewHelper',
                    array('label'),
                    array('HtmlTag', array('tag' => 'div', 'class' => 'multi-select-options')),
                )
            ));

            // I add this to an array for adding into a display group
            $bathroom_display_group[] = $key;
        }

        ...

    }
}

The problem is that when I submit my form, if there are errors (so isValid()) then I lose the values in these input boxes. Could this be a bug or do I need to intercept the code somewhere?