1
Peekay
XoopsForm class validation bug?
  • 2010/5/17 16:14

  • Peekay

  • XOOPS is my life!

  • Posts: 2335

  • Since: 2004/11/20


I am troubleshooting a module and was having trouble validating some required form fields in Xoops 2.3 and 2.4 which worked fine in Xoops 2.0.18.

For example, DHTML text-areas and select menus would not validate if set as required (true).

The relevent xoopsform classes are:

formdhtmltextarea.php and
formselect.php

Looking at the difference between the Xoops versions, I found that the validation script function 'renderValidationJS()' had been added to these classes.

Unfortunately, I think this is causing a conflict with the same script invoked elsewhere in the form, perhaps the main 'form' class?.

When I remove the script function from these classes everything works perfectly.
A thread is for life. Not just for Christmas.

2
Peekay
Re: XoopsForm class validation bug?
  • 2010/5/18 15:46

  • Peekay

  • XOOPS is my life!

  • Posts: 2335

  • Since: 2004/11/20


Actually, the function is present in 'formdhtmltextarea.php' in Xoops 2.0.18.2 too. I was originally using a plain text area.

Likewise, if I comment it out, the validation works.
A thread is for life. Not just for Christmas.

3
Catzwolf
Re: XoopsForm class validation bug?
  • 2010/5/18 16:44

  • Catzwolf

  • Home away from home

  • Posts: 1392

  • Since: 2007/9/30


@Peekay;

You have an example of code this will break the validation?

John

4
Peekay
Re: XoopsForm class validation bug?
  • 2010/5/18 17:45

  • Peekay

  • XOOPS is my life!

  • Posts: 2335

  • Since: 2004/11/20


Hi Catzwolf

In the module I'm working on, the DHTML editor code appears like this:

if ($xoopsModuleConfig['bbcode'] == 1) {
$text_annonce = new XoopsFormDhtmlTextArea(_MD_CATADS_TEXTE_S.'*'"ads_desc"$ads_desc);
} else {
$text_annonce = new XoopsFormTextArea(_MD_CATADS_TEXTE_S.'*'"ads_desc"$ads_desc);
}
$adsform->addElement($text_annoncetrue);


I found that in Xoops 2.0.18.2, the validation worked for the plain text editor, but not the DHTML editor. I thought the editor might need a more direct 'true' condition, so I changed it to this:

if ($xoopsModuleConfig['bbcode'] == 1) {
$adsform->addElement(new XoopsFormDhtmlTextArea(_MD_CATADS_TEXTE_S.'*'"ads_desc"$ads_desc), true);
} else {
$adsform->addElement(new XoopsFormTextArea(_MD_CATADS_TEXTE_S.'*'"ads_desc"$ads_desc), true);
}


But still only the plain text area validated as required.

When I looked at the classes in 2.0.18.2 , The only difference I could see was that the validation function was included in 'formdhtmltextarea.php', but not in 'formtextarea.php'.

When I commented the function out in 'formdhtmltextarea.php', it worked.

Same with Xoops 2.3 and 2.4.

I guess it could be a conflict in the module somewhere, but the code seems valid. I am looking for another module where the DHTML editor field is required, just in case it is an anomoly!
A thread is for life. Not just for Christmas.

5
Peekay
Re: XoopsForm class validation bug?
  • 2010/6/7 20:29

  • Peekay

  • XOOPS is my life!

  • Posts: 2335

  • Since: 2004/11/20


Tiny bump.

Has also been reported here.
A thread is for life. Not just for Christmas.

Login

Who's Online

205 user(s) are online (123 user(s) are browsing Support Forums)


Members: 0


Guests: 205


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Mar 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits