Tag Archive: ajax forms


I was trying to get the content of a form I was building and hooops, where did the fucker go… Unable to get the content of my TextBox element with traditionnal methods like:

data = dijit.byId(“Title”).innerHTML ;

That doesn’t work… because dijits are not dom elements, but objects. Shit I should have known (thanks for IRC dojo channel for answering my so many questions).

What works simply is :

Title = dijit.byId(“Title”).attr(“value”);

And there you go !

Advertisements

The integration of Dojo in the Zend Framework is very nice, it allows us to play with some nice features of this library. Well, let’s get to work, and build a simple login form :

  1. class  LoginForm extends Zend_Dojo_Form
  2. {
  3. public function init()
  4. {
  5. // Dojo-enable the form:
  6. Zend_Dojo::enableForm($this);
  7. $this->setName(‘Login’);
  8. $this->setAction(‘/user/login’)
  9. ->setMethod(‘post’);
  10. // EMAIL
  11. $this->addElement(
  12. ‘ValidationTextBox’,
  13. ’email’,
  14. array(
  15. ‘value’      => ”,
  16. ‘label’      => ‘Email address : ‘,
  17. ‘trim’       => true,
  18. ‘lowercase’  => true,
  19. ‘required’   => true,
  20. ‘regExp’         => ‘^.{4,}$’,
  21. ‘invalidMessage’ => ‘Insert your email’,
  22. ‘validators’ => array(
  23. ‘EmailAddress’,
  24. array(‘StringLength’, false, 4)
  25. ),
  26. ‘filters’  => array(‘StringToLower’),
  27. )
  28. );
  29. // PASSWORD
  30. $this->addElement(
  31. ‘PasswordTextBox’,
  32. ‘password’,
  33. array(
  34. ‘label’          => ‘Password’,
  35. ‘required’       => true,
  36. ‘trim’           => true,
  37. ‘regExp’         => ‘^.{4,}$’,
  38. ‘invalidMessage’ => ‘Invalid password’,
  39. ‘validators’  => array(array(‘StringLength’, false, 4))
  40. )
  41. );
  42. // SUBMIT
  43. $this->addElement(
  44. ‘SubmitButton’,
  45. ‘submit’,
  46. array(
  47. ‘required’   => false,
  48. ‘ignore’     => true,
  49. ‘label’      => ‘Submit Button!’,
  50. )
  51. );
  52. }
  53. }

And it’s pretty straight forward to use :

  1. // initialize the
  2. form = new LoginForm();