Created
March 6, 2014 07:58
-
-
Save dmitrybelyakov/9384493 to your computer and use it in GitHub Desktop.
Revisions
-
dmitrybelyakov created this gist
Mar 6, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ <?php /** * Example action * This is an example action that tests binding of forms to entities. * @return \Zend\View\Model\ViewModel */ public function exampleAction() { $node = new ArrayObject(array( 'id' => 9, 'locale' => 'en_US', 'status' => 'published', 'title' => 'Test', 'slug' => 'test-item', )); $form = new \Zend\Form\Form('example'); //meta $meta = new \Zend\Form\Fieldset('Meta'); $meta->add(new \Zend\Form\Element\Text('title', ['label' => 'Title'])); $form->add($meta); //general $general = new \Zend\Form\Fieldset('General'); $general->add(new \Zend\Form\Element\Text('slug', ['label' => 'Slug'])); $form->add($general); $form->bind($node); $response['form'] = $form; $vm = new ViewModel(array('form' => $form)); $vm->setTemplate('example'); return $vm; } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ <?php $this->form->prepare(); ?> <?= $this->form()->openTag($this->form) ?> <?php foreach ($this->form as $elementOrFieldset): ?> <?php if ($elementOrFieldset instanceof Zend\Form\Fieldset): ?> <?= $this->formCollection($elementOrFieldset) ?> <?php else: ?> <?= $this->formRow($elementOrFieldset) ?> <?php endif; ?> <?php endforeach; ?> <?= $this->form()->closeTag() ?>