Structures_Form_Gtk2
[ class tree: Structures_Form_Gtk2 ] [ index: Structures_Form_Gtk2 ] [ all elements ]

Source for file sfGtk2Example.php

Documentation is available at sfGtk2Example.php

  1. <?php
  2. // A dummy function to show the submitted values.
  3. function dumpValues($values)
  4. {
  5.     var_dump($values);
  6. }
  7.  
  8. // Create a window and set it up to close cleanly.
  9. $window = new GtkWindow();
  10. $window->connect_simple('destroy'array('Gtk''main_quit'));
  11.  
  12. // Create a form.
  13. require_once 'Structures/Form.php';
  14. $form = new Structures_Form('dumpValues');
  15.  
  16. // Register the Gtk2ElementSet.
  17. $form->registerElementSet('Gtk2ElementSet');
  18.  
  19. // Add some elements.
  20. $form->addElement('text',     'username''Username:');
  21. $form->addElement('password''password''Password:');
  22. $form->addElement('cancel',   'cancel');
  23. $form->addElement('submit',   'submit');
  24.  
  25. // Make username required.
  26. $form->addRule('username''required');
  27.  
  28. // Create a group for authentication.
  29. $form->addElement('frame''authentication''Authentication');
  30. $form->addElementToGroup('username''authentication');
  31. $form->addElementToGroup('password''authentication');
  32.  
  33. // Add a text select with user types.
  34. $userTypes $form->addElement('textselect''usertypes''User Type');
  35. $userTypes->addOption('lead',   'Lead');
  36. $userTypes->addOption('helper''Helper');
  37. $userTypes->setValue('lead');
  38.  
  39. // Add a text area.
  40. $form->addElement('textarea''big text block''Some Text',
  41.                   'Some default text.'array(200100)
  42.                   );
  43.  
  44. // Add a file selector.
  45. $form->addElement('file''file''Select a file:',
  46.                   getcwd()Gtk::FILE_CHOOSER_ACTION_OPEN
  47.                   );
  48.  
  49. // Render the form and add it to the window.
  50. $window->add($form->render());
  51.  
  52. // Show the window and start the main loop.
  53. $window->show_all();
  54. Gtk::main();
  55. ?>

Documentation generated on Mon, 11 Mar 2019 14:44:12 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.