Domanda

Usando Zend_Form, come creerei elementi del modulo come questo:

<input type="text" name="element[1]" value="" />
<input type="text" name="element[2]" value="" />
// etc...
È stato utile?

Soluzione

Puoi usare le sottomaschere:

$form = new Zend_Form();

$subForm = new Zend_Form_SubForm();
$subForm->addElement('Text', '1')
        ->addElement('Text', '2');

$form->addSubForm($subForm, 'element');

O dovresti anche essere in grado di usare setBelongsTo () sugli elementi del modulo (non testato):

$form = new Zend_Form();
$form->addElement('Text', '1', array('belongsTo' => 'element'))
     ->addElement('Text', '2', array('belongsTo' => 'element'));

Altri suggerimenti

Sostengo che setBelongsTo sia di qualità scadente, in quanto non è possibile impostare valori predefiniti. E così, al momento, non esiste un modo ragionevole per raggiungere il tuo obiettivo.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top