Form validation (client and serverside)
  • 2005/8/29 13:28

  • Antoine

  • Friend of XOOPS

  • Posts: 112

  • Since: 2004/11/14


I have been doing a lot of module coding the last few months and find myself spending a lot of time trying to sidestep, extend or sometimes even totally ignore the XOOPS forms due to some (as far as i can see) shortcomings. I have a few questions regarding XOOPS forms as they are implemented in the lastest 2.0 release and about potential extentions put there.

1) When using XoopsForms with template files a LOT of undocumented tags seem to get passed to Smarty that need to be wrapped in HTML forms. This hardly seems like a time saver. Am I missing some system that automatically does this wrapping?
Presently I often use output buffering to capture the rendered HTML by the forms to pass that to my templates but that hardly seems like the intended way to use the XOOPS forms.
2) Are there some third party XOOPS form extentions out there that provide any or all of the following?
- Client and server side validation that goes further than just checking wether a textbox contains an empty string.
- Date/time control that accepts and displays date/time according to local settings instead of the default Unix yyyy-mm-dd
- Custom validation message instead of using the control label in validation output.

Any pointers would be much appreciated.


Re: Form validation (client and serverside)
  • 2005/8/30 7:32

  • Antoine

  • Friend of XOOPS

  • Posts: 112

  • Since: 2004/11/14

Hate to do this but: bump.
Anyone know of any XoopsForm mods or have example code of how they can be best made to work with Smarty templates?

Re: Form validation (client and serverside)
  • 2005/8/30 7:47

  • zoullou

  • Quite a regular

  • Posts: 250

  • Since: 2004/3/2 0

I don't use XoopsForm with template. But you can find template varible for XoopsForm in class/xoopsform/form.php in the assign(&$tpl) method.


Re: Form validation (client and serverside)
  • 2005/8/30 9:56

  • McNaz

  • Just can't stay away

  • Posts: 574

  • Since: 2003/4/21

Hi Antoine,

Like you, I have searched for a method to cleanly implement form validation in XOOPS but have not come up with anything usable. There are a few solutions out there (include a promising Smarty based validation engine) but integrating it into XOOPS without hacking the core files (or Smarty class) was almost impossible.

In the end I had to develope a new base class, based on XoopsObject, that would include validation routines, then base all my classes on this.

This meant that I could define :
$this->initVar('zip'XOBJ_DTYPE_TXTBOXnulltrue50'Post Code/Zip');

in the class constructor, for example. This class would then have a validator which would then spit out an array of errors, indexed by field name, for display to the user.

When a form is posted, check the validation. If no errors then save, otherwise, redisplay the form with the passed errors array.

The HTML will look something like

<input type="text" name="zip" value="<{$myvar.zip}>"><div class="error"><{$errors.zip}></div>





Who's Online

68 user(s) are online (29 user(s) are browsing Support Forums)

Members: 0

Guests: 68



Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits