|
Hi,
I've just started playing with Zend, so my problem is probably funny, easy and trivial to solve. But I can not find a solution. Maybe some of you could help me, please. I have a problem with an input of radio type element. I would like to generate HTML form like this: <input type="radio" name="jump[from]" id="jump-from-43" value="43" /> <input type="radio" name="jump[to]" id="jump-to-43" value="43" /> <input type="radio" name="jump[from]" id="jump-from-45" value="45" /> <input type="radio" name="jump[to]" id="jump-to-45" value="45" /> <input type="submit" name="submit" id="submit" value="move" /> It is important that "name" includes associative array. name = "jump [from]" name = "jump [to]" Number of pairs of input (from / to) depends on the number of records in the database, I need to do it dynamically. For now I coped with View helper <?php echo $this->formRadio('jump[from]', null, array(), array($entry->id => '')) ?> <?php echo $this->formRadio('jump[to]', null, array(), array($entry->id => '')) ?> But I would like to have a radio form in the forms dir, together with all forms: (Something similar to this one.) class Application_Form_Panel extends Zend_Form { public function init() { $this->setMethod('post'); $this->addElement('radio', 'jump', array( 'label' => '', 'id' => '', 'multiOptions' => array('' => ''), )); $this->addElement('submit', 'submit', array( 'ignore' => true, 'label' => 'move', )); } } (But I can not make a hash of the jump[from], jump[to].) Then I would like to load in the controller a ViewScript (maybe something like that?) $form->setDecorators(array(array('ViewScript', array('viewScript' => 'someName.phtml')))); <?php foreach ($this->entries as $entry): ?> <input type="radio" name="<?php echo $this->element->firstname->getName(); ?>" id="<?php echo $this->element->firstname->getName(); ?>" value="<?php $entry->id ?>" /> <?php endforeach ?> and, finally, from the views dir drop a line <?php echo $this->form; ?> It is possible WITHOUT View Helper, only via using forms, views and ViewScript? Thank you in advance for your help. rr. |
|
In the documentation can be found: “Zend_Form: Advanced Zend_Form Usage -
Array Notation“ http://framework.zend.com/manual/en/zend.form.advanced.html#zend.form.advanced.arrayNotation Am 18.02.2011, 11:21 Uhr, schrieb Mr.Kilmister <[hidden email]>: > I would like to generate HTML form like this: > > <input type="radio" name="jump[from]" id="jump-from-43" value="43" /> > <input type="radio" name="jump[to]" id="jump-to-43" value="43" /> > > <input type="radio" name="jump[from]" id="jump-from-45" value="45" /> > <input type="radio" name="jump[to]" id="jump-to-45" value="45" /> > > <input type="submit" name="submit" id="submit" value="move" /> > > It is important that "name" includes associative array. > name = "jump [from]" > name = "jump [to]" |
|
WOW
exactly what I was looking for, thanks a lot
|
| Powered by Nabble | Edit this page |
