1
TheFinni
xoopsform validation for select and tray
  • 2006/2/15 19:43

  • TheFinni

  • Just popping in

  • Posts: 75

  • Since: 2003/11/25


Hello,
I have a couple of questions on xoopsform classes.

I'm in the process of editing the Extended Profiles registration form (with some hacks). I am adding the form elements manually instead through the Administration panel (this is required in my hack).

However I can't figure out how to make XoopsFormElementTray and XoopsFormSelect reuired items. I.e. included in the javascript validation.

For instance in XoopsFormText I would add the (,true); to make it required:
$reg_form->addElement(new XoopsFormText("First Name"'firstname'5080$firstname), true);


However how would I do it in a XoopsFormSelect?

I have:
$state_select = new XoopsFormSelect("State""entry_state"$set_state);
    
$state_select->addOption('''Please Select');
        while (list(
$zone_id$zone_name) = $xoopsDB->fetchRow($zones_query) ) {
             
$state_select->addOption($zone_id$zone_name);
        }

    
$reg_form->addElement($state_select);


I would also like to know how to make the XoopsFormElementTray required. For instance I would like to conver the password field:
$reg_form->addElement(new XoopsFormPassword(_PROFILE_MA_PASSWORD"pass"1032""), true);

so that I could display to the user how many characters are needed in the password:
$pass_tray = new XoopsFormElementTray(_PROFILE_MA_PASSWORD);
    
$pass_tray->addElement(new XoopsFormPassword(''"pass"1032""), true);
    
$pass_tray->addElement(new XoopsFormLabel(''$xoopsModuleConfig['minpass'].' characters minimum'));
    
$reg_form->addElement($pass_tray);


If anyone has an idea I would appreciate it. I am also looking at being able to add server-side validation for some of my fields.

Thank you!

2
TheFinni
Re: xoopsform validation for select and tray
  • 2006/2/15 23:05

  • TheFinni

  • Just popping in

  • Posts: 75

  • Since: 2003/11/25


Nevermind, I figured it out on my own. Here's what I did:

You can set a required field by:

$reg_form->setRequired($your_required_field);

For the state field I did:

$state_select = new XoopsFormSelect("State""entry_state"$set_state);
    
$state_select->addOption('''Please Select');
        while (list(
$zone_id$zone_name) = $xoopsDB->fetchRow($zones_query) ) {
             
$state_select->addOption($zone_id$zone_name);
        }

    
$reg_form->addElement($state_select);
    
$reg_form->setRequired($state_select);


and the password was slightly trickier. But I think it's worth to show the user in advance how many characters is required:
$pass_item1 = new XoopsFormPassword('''pass'1032'');
    
$pass_item2 = new XoopsFormLabel(''$xoopsModuleConfig['minpass'].' characters minimum');
    
$pass_tray = new XoopsFormElementTray(_PROFILE_MA_PASSWORD,' ','pass');
    
$pass_tray->addElement($pass_item1);
    
$pass_tray->addElement($pass_item2);
    
$reg_form->addElement($pass_tray);
    
$reg_form->setRequired($pass_tray);

Login

Who's Online

209 user(s) are online (124 user(s) are browsing Support Forums)


Members: 0


Guests: 209


more...

Donat-O-Meter

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

Latest GitHub Commits