User Login    
 + Register
  • Main navigation
Login
Username:

Password:

Remember me



Lost Password?

Register now!
Who's Online
86 user(s) are online (10 user(s) are browsing XoopsWiki)

Members: 2
Guests: 84

ongkettt, caek9, more...
[Main Page]

Dev:using xoops form library

From XOOPS Project

Main Page | Recent changes | Edit this page | Page history | Switch to MediaWiki mode

Printable version | Disclaimers | Privacy policy
Category: Development

Using the XoopsForm library

For a visual overview of the various classes used in constructing forms check out the UML Class Diagram.

XOOPS comes with a selection of Form Classes, ready to use.

Using the form classes starts with including the form classes through the xoopsformloader.php:

include XOOPS_ROOT_PATH."/class/xoopsformloader.php";

After this include, you are able to use any of the XoopsForm classes.

Using XoopsForm Classes

The order of instantiating the XoopsForm elements is not important, but we'll start off with making the Form object:

   $testform = new XoopsForm('Title of form', 'name of form', 'url to action-receiving page', 'POST/GET method');


The form defaults to POST method if none chosen. Available forms are XoopsThemeForm, XoopsTableForm? and XoopsSimpleForm, all of which inherits from XoopsForm - XoopsForm itself is an abstract class and should not be instantiated on its own, but instead one of the child classes, e.g.

   $testform = new XoopsSimpleForm('Title of form', 'name of form', 'url to action-receiving page', 'POST/GET method');


Next, we want to add elements to the form. Available elements are:

  1. XoopsFormLabel
  2. XoopsFormSelect
  3. XoopsFormText
  4. XoopsFormCheckBox
  5. XoopsFormRadio
  6. XoopsFormHidden
  7. XoopsFormHiddenToken
  8. XoopsFormFile
  9. XoopsFormPassword
 10. XoopsFormButton
 11. XoopsFormTextArea
 12. XoopsFormDhtmlTextArea
 13. XoopsFormDateTime


Elements are added with

   $testform->addElement(&$element, $required = false);


If you want to add more to the element (accesskey or similar) you should first make the object, then set the accesskey etc. before sending the object with the addElement method. Otherwise, you can instantiate the object directly in the addElement method, e.g. like this:

   $testform->addElement(new XoopsFormText($name, $desc, $size, $maxlength, $value));


Add the elements you want and finish off the form with a

   $testform->display();


Back to the Main Page

Retrieved from "http://www.xoops.org/modules/mediawiki/index.php/Dev:using_xoops_form_library"

This page has been accessed 635 times. This page was last modified 01:54, 16 December 2007. Content is available under XOOPS Project.


Developers for Hire
Developers for Hire
Local Support Sites
Make a donation
Please select an amount to donate


Do you want your username revealed with your donation?
Yes - List me as a Generous Donor
No - List my donation as from an Anonymous Donor


Powered by
XOOPS Code hosted on SourceForge

Powered by PHP

PHP 5

Powered by MySQL

Powered by Smarty

OSI certified

GPL

All content on this site is subject to the Creative Commons License
Top Tags
Theme (5) news (2) security (2) sport (1) Arabic (1) wiki (1) Christmas (1) jQuery (1) tag (1) module (1) SEO (1) comments (1)
Advertisement