Ok, now I have to check-out the Formulize myself. Sounds like a good module!
For those who are using the SmartProfile module I have a couple more fixes.
The form seems to miss the "name" tag in templates/smartprofile_register.html. Without the name the javascript xoopsFormValidate validation won't function.
Simply add 'name="<{$regform.name}>"' to the file.
I also noticed the insertBreak didn't produce Category headings in the template. And I wanted to be able to tell the user if a field was required or not. I'm going to copy/paste my new version of the assign function of the register.php file.
PLEASE NOTE THIS IS FOR THE PHP4 version from xooobs.net (you can modify the if object else easily for php5).
function assign($form, $tpl) {
global $xoopsTpl;//TN added
$js = $form->renderValidationJS(); //TN moved from bottom of function so I can mark fields as required
//TN get/parse required fields
preg_match_all('/myform.[a-zA-Z0-9_]+.value/i', $js, $match);
$req_fields = $match[0];
$patterns[0] = '/myform./';
$patterns[1] = '/.value/';
$replacements[0] = '';
$replacements[1] = '';
$req_fields = preg_replace($patterns, $replacements, $req_fields);
$i = 0;
$elements = array();
foreach ( $form->getElements() as $ele ) {
if (is_a($ele,'XoopsFormElement')) {
$n = ($ele->getName() != "") ? $ele->getName() : $i;
$elements[$n]['name'] = $ele->getName();
$elements[$n]['caption'] = $ele->getCaption();
$elements[$n]['body'] = $ele->render();
$elements[$n]['hidden'] = $ele->isHidden();
if ($ele->getDescription() != '') {
$elements[$n]['description'] = $ele->getDescription();
}
//TN added for required field (getRequired() doesn't work here so use array from preg_match_all above:
if((isset($req_fields) && is_array($req_fields)) && (in_array($n,$req_fields))){
$elements[$n]['required'] = true;
}
//TN EOF
} else {//TN not an object and likely insertBreak. let's assign:
$elements['ibreak'.$i]['ibreak'] = $ele;
}
$i++;
}
//js validate form:$xoopsTpl->assign($form->getName(), array('title' => $form->getTitle(), 'name' => $form->getName(), 'action' => $form->getAction(), 'method' => $form->getMethod(), 'extra' => 'onsubmit="return xoopsFormValidate_'.$form->getName().'();"'.$form->getExtra(), 'javascript' => $js, 'elements' => $elements));
$xoopsTpl->assign($form->getName(), array('title' => $form->getTitle(), 'name' => $form->getName(), 'action' => $form->getAction(), 'method' => $form->getMethod(), 'javascript' => $js, 'elements' => $elements));
}
Then you can modify the smartprofile_register.html file to use "$element.ibreak" and "$element.required".
Here's my template:
<div>
<{foreach item=step from=$steps key=stepno name=steploop}>
<{if $stepno < $current_step}>
<a href="<{$xoops_url}>/modules/smartprofile/register.php?step=<{$stepno}>">
<{elseif $stepno == $current_step}>
<b>
<{/if}>
<{$step.step_name}>
<{if $stepno < $current_step}>
a>
<{elseif $stepno == $current_step}>
b>
<{/if}>
<{if !$smarty.foreach.steploop.last}>
»
<{/if}>
<{/foreach}>
div>
<{if $stop}>
<div class='errorMsg'><{$stop_headline}><{$stop}>div>
<br clear='both'>
<{/if}>
<{if $confirm}>
<{foreach item=msg from=$confirm}>
<div class='confirmMsg'><{$msg}>div>
<br clear='both'>
<{/foreach}>
<{/if}>
<{if $regform}>
<span style="font-size: x-small; color: red;"><{$smarty.const._PROFILE_AM_REG_REQ_TXT}>span>
<form name="<{$regform.name}>" id="<{$regform.name}>" action="<{$regform.action}>" method="<{$regform.method}>" <{$regform.extra}> >
<table width="100%" class="outer" cellspacing="1">
<tr><th colspan="2"><{$regform.title}>th>tr>
<{foreach item=element from=$regform.elements}>
<{if $element.ibreak}><{$element.ibreak}><{else}>
<{if !$element.hidden}>
<tr valign='top' align='left'>
<td class='head'><{$element.caption}><{if $element.description != ""}><br /><span style="font-weight: normal; font-size: x-small;"><{$element.description}>span><{/if}>td>
<td class="<{cycle values='odd, even'}>"><{$element.body}><{if $element.required}> <span style="font-size: x-small; color: red;">*span><{/if}>td>
tr>
<{/if}><{/if}>
<{/foreach}>
table>
<{foreach item=element from=$regform.elements}>
<{if $element.hidden}>
<{$element.body}>
<{/if}>
<{/foreach}>
form>
<{$regform.javascript}>
<{/if}>