Get XOOPS XOOPSXOOPS FAQFAQ ForumsForums NewsNews ThemesThemes ModulesModules

Search

Donate to XOOPS!

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


Local Support

Advertisement

XOOPS Code hosted on SourceForge

Cumulus Tag Cloud

admin Arabic banner block Christmas comments cumulus DayDawn dhsoft e-Commerce E-Learning Git Google GUI hacks instant-zero jQuery module mygalleries news Nordic Olédrion oxygen PageRank PHP rmcommon security SEO simple-XOOPS Smarty sport tag Theme tutorial wiki WOX xoops XoopsEngine ZendFramework

New Users

Registering user

# 133946

HamptonUdolf

Welcome to XOOPS!
[Main Page]

Dev:using xoops form library

From XOOPS Web Application System

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://xoops.org/modules/mediawiki/index.php/Dev:using_xoops_form_library"

This page has been accessed 2,702 times. This page was last modified 01:54, 16 December 2007. Content is available under XOOPS Web Application System.