Guest User

Untitled

a guest
Jun 13th, 2012
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.99 KB | None | 0 0
  1. //getting the form
  2. $name = new Element('name');
  3.         $name->setAttributes(array('type' => 'text', 'label' => 'Your name'));
  4. $form = new Form('contact');
  5.         $form->add($name);
  6.  
  7. // than I return the form to view
  8. public function indexAction ()
  9.     {
  10.         return new ViewModel(array('form' => $this->getForm()));
  11.     }
  12.  
  13. //in view
  14. <?php
  15. // within a view script
  16. $form = $this->form;
  17. $form->prepare();
  18. // Assuming the "contact/process" route exists...
  19. $form->setAttribute('action', 'contact/process');
  20. // Set the method attribute for the form
  21. $form->setAttribute('method', 'post');
  22. // Render the opening tag
  23. echo $this->form()->openTag($form);
  24. ?>
  25. <div class="form_element">
  26. <?php
  27. $name = $form->get('name');
  28. echo $this->formLabel()->openTag($name);
  29. echo $this->formInput($name);
  30. echo $this->formElementErrors($name);
  31. echo $this->formLabel()->closeTag();
  32. ?></div>
  33.  
  34. // 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