Quantcast
Channel: PHP Website Development » ZF
Viewing all articles
Browse latest Browse all 12

ZF: Zend_Form_SubForm display elements in the View on one’s

$
0
0

My task is to create list of inputs which have name like photoForm[name][1]. If I do print $this->form in the view – that is ok. All fields are good.
But I don’t wanna use decorator and I would like to compile on one’s own. (just leave ViewHelper and FormElements for displaying in the View)
I run this code in the view:
foreach($this->mainform->getSubForm(‘photoForm’)->getSubforms() as $form)
{
foreach($form->getElements() as $element)
{
print $element;
}
}And get follow input:
But I would like to see follow code instead:
How to print it correct?
This is my simplified source code for good understandig:
function addInput($name, $id, $value)
{
global $photoForm;

$input = new Zend_Form_Element_Text($name);
$input->setValue($value);

$subform = new Zend_Form_SubForm(();
$subform->addElement($input);

$photoForm->getSubForm(‘photoForm’)->addSubForm($subform, $id);
}

function submitInput()
{
$input = new Zend_Form_Element_Submit(‘submit’);
$input->setLabel(‘Save’);

return $input;
}

$photoForm = Zend_Form();

$subform = new Zend_Form_SubForm();

$photoForm->addSubForm($subform, ‘photoForm’);
$photoForm->addElement(submitInput());

addInput(‘name’, 1, ‘value’);
………………………….

So I found an answer.
Thx to http://stackoverflow.com/users/220922/fimbulvetr


Viewing all articles
Browse latest Browse all 12

Latest Images

Trending Articles





Latest Images