1
bumciach
XoopsForm and ajax empty response
  • 2009/8/7 8:06

  • bumciach

  • Not too shy to talk

  • Posts: 153

  • Since: 2007/6/25


I use xajax to validate the form.

At the beginning of what works:

index.php
$xoopsOption['template_main'] = 'my_form_template.tpl';    
$form = new XoopsThemeTabForm(...);
...
$form->display();

my_form_template.tpl
<div id="form-element-alert">div>


The form shows below the 'form-element-alert'. If the input is empty (onBlur event), the div 'form-element-alert' shows message 'EMPTY'. If something is written into the input field, the message is 'OK'.

THE PROBLEM:
I did my own template form (div 'form-element-alert' box on every form element) in my_form_template.tpl, so I used $ form-> assign instead of $ form-> display

index.php
$xoopsOption['template_main'] = 'my_form_template.tpl';    
$form = new XoopsThemeTabForm(...);
...
$form->assign($xoopsTpl);


And now also the form is displayed correctly. But xajax sends an empty response, so always displays the message 'EMPTY'.

xajax debug:
POSTxjxfun=symbolExist
&xjxr=1249628528828
&xjxargs[]=
<
xjxobj>
xjxobj>

but should be
POSTxjxfun=symbolExist
&xjxr=1249631398417
&xjxargs[]=
<
xjxobj>
<
e><k>symbolk><v>v>e>
...
<
e><k>submitk><v>CDATA[Save this form]]>v>e>
<
e><k>cancelk><v>Cancelv>e>
<
e><k>idk><v>v>e>
<
e><k>opk><v>newv>e>
xjxobj>

2
bumciach
Re: XoopsForm and ajax empty response
  • 2009/8/7 12:33

  • bumciach

  • Not too shy to talk

  • Posts: 153

  • Since: 2007/6/25


OK, found that it's the problem of browser not Xoops.
Now it works under IE (although there were some charset problems earlier). But under Firefox still no data sends from form during xajax response. Arghh...

3
bumciach
Re: XoopsForm and ajax empty response
  • 2009/8/10 8:00

  • bumciach

  • Not too shy to talk

  • Posts: 153

  • Since: 2007/6/25


Now it's working on Firefox too! I have overlooked that no id attribute in the form element. Stupid :P

4
urbanspacema
Re: XoopsForm and ajax empty response

can you share the code?
tnx

5
bumciach
Re: XoopsForm and ajax empty response
  • 2009/8/10 11:26

  • bumciach

  • Not too shy to talk

  • Posts: 153

  • Since: 2007/6/25


Class XoopsThemeTabForm comes from the Publisher module by Trabis.
I am currently just testing different things, so I can show you only this:

index.php
$xajax = new xajax();

if ( 
_CHARSET == 'ISO-8859-2' ) {
  
$xajax->configure("characterEncoding"'ISO-8859-2');
  
$xajax->configure('decodeUTF8Input',true);
}
$xajax->setFlag("debug"false);
$xajax->register(XAJAX_FUNCTION,"symbolExist");
$xajax->processRequest();
$Xjavapath=BAZLE_AJAXLIB_URL;
$xajaxjava=$xajax->getJavascript($Xjavapath);

$xoopsOption['template_main'] = 'my_form_template.tpl';    

/**
 * XOOPS main header file
 */

require_once XOOPS_ROOT_PATH."/header.php";    


include_once 
XOOPS_ROOT_PATH."/class/xoopsformloader.php";
  include_once 
BAZLE_PATH '/class/themetabform.php';
  
$cform = new XoopsThemeTabForm('Title of form''frmObiekt''umenu0.php?op='.$akcja);
     
$cform->setExtra('enctype="multipart/form-data"');
  
$cform->startTab('Symbol');
    
//SYMBOL
    
$tray_symbol = new XoopsFormElementTray_BAZLE_SYMBOL'''symbol' );
    
$symbol_frm=new XoopsFormText('''symbol'2010$row_obiekt['symbol']);
    if(
$op=='new')
        
$symbol_frm->setExtra(' onBlur="xajax_symbolExist(xajax.getFormValues('."'frmObiekt'".'));"');
    
$tray_symbol->addElement($symbol_frmtrue);
      
$cform->addElement($tray_symboltrue);
    
    
$cform->startTab('Other');
      
//UWAGI
      
$cform->addElement(new XoopsFormTextArea(_BAZLE_UWAGI'uwagi'$row_obiekt['uwagi'], 4$cols=50), false);
      
$cform->endTabs();
    
      
//SUBMIT
      
$cform->addElement(new XoopsFormHidden('id'$id), false);
      
$cform->addElement(new XoopsFormHidden('op'$op), false); 
      
$button_tray = new XoopsFormElementTray('' ,'');
      
$submit_btn = new XoopsFormButton('''sbt'_SUBMIT'submit');
      
$button_tray->addElement($submit_btn);
      
$cancel_btn = new XoopsFormButton('''cancel'_CANCEL'button');
      
$cancel_btn->setExtra("onClick="document.location.href='".BAZLE_URL."/index_obiekty.php';"");
      
$button_tray->addElement($cancel_btn);
    
$cform->addElement($button_tray);
     
     
$cform->assign($xoopsTpl);

$xoopsTpl->assign('xajaxjava'$xajaxjava);

$xoTheme->addStylesheet(BAZLE_URL '/css/publisher.css');
$xoTheme->addStylesheet(BAZLE_URL '/css/jquery-ui-1.7.1.custom.css');

$xoTheme->addScript(BAZLE_URL '/js/jquery-1.3.2.min.js');
$xoTheme->addScript(BAZLE_URL '/js/jquery-easing-1.3.pack.js');
$xoTheme->addScript(BAZLE_URL '/js/jquery.lightbox-0.5.js');
$xoTheme->addScript(BAZLE_URL '/js/jquery.popeye-0.2.1.js');
$xoTheme->addScript(BAZLE_URL '/js/ui.core.js');
$xoTheme->addScript(BAZLE_URL '/js/ui.tabs.js');
$xoTheme->addScript(BAZLE_URL '/js/publisher.js');

include_once 
XOOPS_ROOT_PATH '/footer.php';


my_form_template.tpl
<div id="tabs">
<
ul>
<{foreach 
item=tab key=key from=$frmObiekt.tabs}>
  <
li><a href="#tab_<{$key}>"><span><{$tab}>span>a>li>
<{/foreach}>
ul>

<
form name="<{$frmObiekt.name}>" id="<{$frmObiekt.name}>" action="<{$frmObiekt.action}>" method="<{$frmObiekt.method}>" <{$frmObiekt.extra}>>

  <{foreach 
item=tab key=key from=$frmObiekt.tabs}>
  <
div id="tab_<{$key}>">
    <
table class="outer" cellspacing="1">
    <
tr><th colspan="2"><{$frmObiekt.title}>th>tr>
    <{foreach 
item=element from=$frmObiekt.elements}>
    <{if 
$element.tab == $key || $element.tab == -1}>
    <{if !
$element.hidden}>
      <
tr>
        <
td class="head">
        <{if 
$element.caption != ''}>
          <
div class="xoops-form-element-caption<{if $element.required}>-required<{/if}>">
            <
span class="caption-text"><{$element.caption}>span>
                  <
span class="caption-marker">*span>
          div>
        <{/if}>
        <{if 
$element.description}>
            <
div class="xoops-form-element-help"><{$element.description}>div>
        <{/if}>
        td>
        <
td id="xoops-form-element-body_<{$element.name}>" class="even"><{$element.body}><div class="xoops-form-element-alert" id="xoops-form-element-alert_<{$element.name}>">div>td>
      tr>
    <{/if}>
    <{/if}>
    <{/foreach}>
    
    table>
  div>
  <{/foreach}>
  <{foreach 
item=element from=$frmObiekt.elements}>
      <{if 
$element.hidden}><{$element.body}><{/if}>
  <{/foreach}>
  
form>  <{$frmObiekt.javascript}>
div>
<{
$xajaxjava}>

Login

Who's Online

329 user(s) are online (269 user(s) are browsing Support Forums)


Members: 0


Guests: 329


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