Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //getting the form
- $name = new Element('name');
- $name->setAttributes(array('type' => 'text', 'label' => 'Your name'));
- $form = new Form('contact');
- $form->add($name);
- // than I return the form to view
- public function indexAction ()
- {
- return new ViewModel(array('form' => $this->getForm()));
- }
- //in view
- <?php
- // within a view script
- $form = $this->form;
- $form->prepare();
- // Assuming the "contact/process" route exists...
- $form->setAttribute('action', 'contact/process');
- // Set the method attribute for the form
- $form->setAttribute('method', 'post');
- // Render the opening tag
- echo $this->form()->openTag($form);
- ?>
- <div class="form_element">
- <?php
- $name = $form->get('name');
- echo $this->formLabel()->openTag($name);
- echo $this->formInput($name);
- echo $this->formElementErrors($name);
- echo $this->formLabel()->closeTag();
- ?></div>
- // i expect the "formLabel" to echo the label. It does. But the label is empty - the "Your name" is missing.
Advertisement
Add Comment
Please, Sign In to add comment