Zend form input name with same name

2019-09-23 01:44发布

问题:

Using Zend 1.9 I am trying to generate a form using Zend Form module . My form should be like this:

<form method="post" action="myaction">

    <input type="text" name="editors[]" />
    <input type="text" name="editors[]" />
    <input type="text" name="editors[]" />
    <input type="text" name="editors[]" />

    <button type="submit" >Go</button>

</form>

When I submit the form in my controller I want to see something like this:

Zend_Debug::dump($this->getAllParams());

//I expect this output:
array (size=4)
  'controller' => string 'myCotnroller' (length=8)
  'module' => string 'MyModule' (length=14)
  'action' => string 'test' (length=4)
  'editors' => 
    array (size=4)
      0 => string '' (length=3)
      1 => string '' (length=0)
      2 => string '' (length=0)
      3 => string '' (length=0)

I the last week I tried many and many times with no result. I have search whitout any goog result . Can you help me?

回答1:

I hope some of these will help on your quest.
Zend Framework: Working with Form elements in array notation
Advanced Zend_Form Usage
Zend_Form - Array based elements?
How do configure Zend_Form to use array notation?