1
Codyko
Form validation using XoopsForm and smarty template
  • 2006/1/5 8:07

  • Codyko

  • Just popping in

  • Posts: 22

  • Since: 2005/8/5 7


Hi! I am using XOOPS version 2.2.3. I have problem when using form validation with xoopsform and smarty template together;

Ok, I have the form like this :

$form = new XoopsThemeForm($formTitle"categoryform"$formAction"POST");
$form->addElement(new XoopsFormText(_MD_XINVENTORY_CATEGORY_NAME"catname"3060,$catNameValue),true);
$form->assign(&$xoopsTpl);


The form can be rendered through a template but I found that form validation at the "catname" field doesn't work unless I change. ie. It won't warn of empty string.

$form->assign(&$xoopsTpl)
to
$form->display()


I notice that when using the display() method, a "*" is marked beside the "catname", but there is no such mark when using the
template method.

Any idea ?

Thanks
Cody

2
Codyko
Re: Form validation using XoopsForm and smarty template
  • 2006/1/6 8:47

  • Codyko

  • Just popping in

  • Posts: 22

  • Since: 2005/8/5 7


Hi all,

Sugar, aka RB , the Author of the magazine module is so nice that he provided me some hints at our local support site. Finally, I have solved the problem. Here is the summary of the solution :

1. Using xoopsform methods , create the prefered form eg include/form.inc.php :

$form = new XoopsThemeForm($formTitle"categoryform"$formAction"POST");
$form->addElement(new XoopsFormText(_MD_XINVENTORY_CATEGORY_NAME"catname"3060,$catNameValue),true );
[
color=0000FF]return $categoryForm->render();[/color]
?>


2.In the php script eg submit.php where you need to use this form
 //codes ......
 
$xoopsOption['template_main'] = xinventory_category.html";
    include "
../../header.php";
//----------------
$form = include "include/form.inc.php";
$xoopsTpl->assign('form',$form);
//---------------
?>


3. Finally, in the smarty temmplate , ie templates/xinventory_category.html :
<{$form}>


One more interest thing is that, I cannot not use $form->insertBreak() in "include/form.inc.php" if I don't use $form->display(); but the above solution can get rid of this.

Hope this helps others !

Regards
Cody

Login

Who's Online

355 user(s) are online (256 user(s) are browsing Support Forums)


Members: 0


Guests: 355


more...

Donat-O-Meter

Stats
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