1
zzzzsg
Formulaire Select Box problem
  • 2005/12/30 1:43

  • zzzzsg

  • Just popping in

  • Posts: 86

  • Since: 2005/12/22


hi Everybody

I am using Formulaire 3.23 on XOOPS 2.2.3 and cannot get the Select Box working. The Options for the Select Box just disappear.

And I am also getting this error
"Fatal error: Call to undefined function: getbymodule() in /usr/local/www/data-dist/xoops2/modules/formulaire/admin/myblocksadmin.php on line 72" when I click on Blocks and Groups in the Formulaire administration.

Formulaire 3.23 is not compatible with XOOPS 2.2.3, as I have no problem with Formulaire 3.23 on XOOPS 2.0.13.2

Can anybody help?


Thank you very much in anticipation.

gui

2
fipoo
Re: Formulaire Select Box problem
  • 2008/7/10 21:47

  • fipoo

  • Just popping in

  • Posts: 11

  • Since: 2005/9/9 0


Same problem!
I am using Formulaire 3.3 on XOOPS 2.2.4 and either cannot get the Select Box working.
The Options for the Select Box just disappear.

Can Somebody help us?
Thanks!

3
ghia
Re: Formulaire Select Box problem
  • 2008/7/10 23:13

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


Here it works XOOPS V2.2.6 and Formulaire 3.33 (I recommend upgrading your software to this level) with patches from here and here (French).

Is this disappearing in Admin (setup of a form) or in user mode (fill in)? Can you tell more about the functions used and actions taken, which leads to the faulty result?

4
fipoo
Re: Formulaire Select Box problem
  • 2008/7/11 0:17

  • fipoo

  • Just popping in

  • Posts: 11

  • Since: 2005/9/9 0


Ok... Here is what I have done:

I created a form item clicking on the Select Box link.
Then I filled the two default options before adding more two options (I need 4 options in this item).
Then, when I clicked in the Ok button my site has returned to the form modification page with the form item recently created there, but with an empty selection box!

In the user mode of the form, the select box is empty too!

5
ghia
Re: Formulaire Select Box problem
  • 2008/7/11 8:26

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


Strange, I retested here and I observe the same problem.
I had used it once, but decided than that is was easier for users to select (with 2 - 4 selections) from radiobuttons.
I will try to look into it.

6
ghia
Re: Formulaire Select Box problem
  • 2008/7/12 10:19

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


I found out that the things for this particular form element of Formulaire get wrong encoded in the database:
ele_value in table prefix_form is:
a:3:{i:0;s:1:"1";i:1;s:1:"1";i:2;s:5:"Array";}

and should be (selection of three options)
a:3:{i:0;i:1;i:1;i:0;i:2;a:3:{s:8:"Option 1";i:1;s:8:"Option 2";i:0;s:8:"Option 3";i:0;}}

Got it from the SQL for the example form with fresh install.
This renders OK in the form (user to fill in), edit form (admin) and edit element (admin).
So the problem lies probably in the gathering of the data from the form and storing these in the database.

This is the html for the form.

<form name='form_ele' id='form_ele' action='elements.php?id=15' method='POST'  onsubmit="return xoopsFormValidate_form_ele();">
<
input type='hidden' name='skipValidationJS' id='skipValidationJS' value='0' />
<
input type='hidden' name='op' id='op' value='save' />
<
input type='hidden' name='ele_type' id='ele_type' value='select' />
<
input type='hidden' name='ele_id' id='ele_id' value='144' />
<
table width='100%' class='outer' cellspacing='1'><tr><th colspan='2'>Edit form elementddd</th></tr><tr valign='top' align='left'><td class='head'>Caption's name *</td><td class='even'><input type='text' name='ele_caption' id='ele_caption' size='50' maxlength='255' value='ddd' /></td></tr><tr valign='top' align='left'><td class='head'>Size *</td><td class='even'><input type='text' name='ele_value[0]' id='ele_value[0]' size='3' maxlength='2' value='1' /></td></tr><tr valign='top' align='left'><td class='head'>Allow multiple selections</td><td class='even'><input type='radio' id='ele_value[1]0' name='ele_value[1]' value='1' />Ja

<input type='
radio' id='ele_value[1]1' name='ele_value[1]' value='0' checked='checked' />Nee
</td></tr><tr valign='
top' align='left'><td class='head'>Options<br /><br /><span style="font-weight: normal;">Tick the check boxes for selecting default values<br />Only the first checked is used if multiple selection is not allowed</span></td><td class='even'><input type='checkbox' id='checked[0]0' name='checked[0]' value='1' checked='checked' /> 

&nbsp;<input type='
text' name='ele_value[2][0]' id='ele_value[2][0]' size='40' maxlength='255' value='Option 1' />

<br /><input type='
checkbox' id='checked[1]0' name='checked[1]' value='1' /> 

&nbsp;<input type='
text' name='ele_value[2][1]' id='ele_value[2][1]' size='40' maxlength='255' value='Option 2' />

<br /><input type='
checkbox' id='checked[2]0' name='checked[2]' value='1' /> 

&nbsp;<input type='
text' name='ele_value[2][2]' id='ele_value[2][2]' size='40' maxlength='255' value='Option 3' />

<br />Add <input type='
text' name='addopt' id='addopt' size='3' maxlength='2' value='' /> options
&nbsp;<input type='
submit' class='formButton' name='submit'  id='submit' value='Add' />

</td></tr><tr valign='
top' align='left'><td class='head'>Required</td><td class='even'><input type='checkbox' id='ele_req0' name='ele_req' value='1' /> 
</td></tr><tr valign='
top' align='left'><td class='head'>Display</td><td class='even'><input type='checkbox' id='ele_display0' name='ele_display' value='1' checked='checked' /> 
</td></tr><tr valign='
top' align='left'><td class='head'>Order</td><td class='even'><input type='text' name='ele_order' id='ele_order' size='3' maxlength='2' value='0' /></td></tr><tr valign='top' align='left'><td class='head'></td><td class='even'><input type='submit' class='formButton' name='submit'  id='submit' value='Save' />
&nbsp;<input type='
button' class='formButton' name='cancel'  id='cancel' value='Niet doen'onclick="javascript:history.go(-1);" />
</td></tr><tr class='
foot'><td colspan='2'>* = Vereist</td></tr></table>
</form>


I found this remarks on naming and giving an id to the fields. I do not know if this is relevant or not.

The code for processing this form is in formulaire/admin/elements.php .

<?php

include_once("admin_header.php");

if ( 
file_exists("../language/".$xoopsConfig['language']."/modinfo.php") ) {
    include 
"../language/".$xoopsConfig['language']."/modinfo.php";

else {
    include 
"../language/english/modinfo.php";
}

if(!isset(
$_POST['id'])){
    
$id = isset ($_GET['id']) ? $_GET['id'] : '';
}else {
    
$id $_POST['id'];
}
if(!isset(
$_POST['ele_id'])){
    
$ele_id = isset ($_GET['ele_id']) ? $_GET['ele_id'] : '';
}else {
    
$ele_id $_POST['ele_id'];
}
if(!isset(
$_POST['ele_type'])){
    
$ele_type = isset ($_GET['ele_type']) ? $_GET['ele_type'] : '';
}else {
    
$ele_type $_POST['ele_type'];
}

if(!isset(
$clone)){ $clone="";}
if(!isset(
$req)){ $req="";}
if(!isset(
$text)){ $text="";}
if(!isset(
$_POST['submit'])){ $_POST['submit']="";}

$sql=sprintf("SELECT desc_form FROM ".$xoopsDB->prefix("form_id")." WHERE id_form='%s'",$id);
$res $xoopsDB->query($sql) or die('Erreur SQL !<br />'.$requete.'<br />'.$xoopsDB->error());

if (
$res) {
  while ( 
$row $xoopsDB->fetchRow($res)) {
    
$title $row[0];
  }
}

if( !empty(
$_POST) ){
    foreach( 
$_POST as $k => $v ){
        ${
$k} = $v;
    }
}elseif( !empty(
$_GET) ){
    foreach( 
$_GET as $k => $v ){
        ${
$k} = $v;
    }
}

$ele_id = !empty($ele_id) ? intval($ele_id) : 0;
$myts =& MyTextSanitizer::getInstance();

if (isset(
$_POST))
{
    foreach (
$_POST as $k => $v)
    {
        $
$k $v;
    } 


if (isset(
$_GET))
{
    foreach (
$_GET as $k => $v)
    {
        $
$k $v;
    } 
}

if( 
$_POST['submit'] == _AM_ELE_ADD_OPT_SUBMIT && intval($_POST['addopt']) > ){
    
$op 'edit';
}

    if (
$ele_type == "text")
    {    
$name _AM_ELE_TEXT;
    } elseif  (
$ele_type == "textarea")
    {    
$name _AM_ELE_TAREA;
    } elseif  (
$ele_type == "areamodif")
    {    
$name _AM_ELE_MODIF;
    } elseif  (
$ele_type == "select")
    {    
$name _AM_ELE_SELECT;
    } elseif  (
$ele_type == "checkbox")
    {    
$name _AM_ELE_CHECK;
    } elseif  (
$ele_type == "radio")
    {    
$name _AM_ELE_RADIO;
    } elseif  (
$ele_type == "yn")
    {    
$name _AM_ELE_YN;
    } elseif  (
$ele_type == "date")
    {    
$name _AM_ELE_DATE;
    } elseif  (
$ele_type == "sep")
    {    
$name _AM_ELE_SEP;
    } elseif  (
$ele_type == "upload")
    {    
$name _AM_ELE_UPLOAD;
    } elseif  (
$ele_type == "mail")
    {    
$name _AM_ELE_MAIL;
    } elseif  (
$ele_type == "mailunique")
    {    
$name _AM_ELE_MAIL;
    }

switch(
$op){
    case 
'edit':
// snipped
    
break;
    case 
'delete':
// snipped
    
break;
    case 
'save':
        if( !empty(
$ele_id) ){
            
$element =& $formulaire_mgr->get($ele_id);
        }else{
            
$element =& $formulaire_mgr->create();
        }
        
$element->setVar('ele_caption'$ele_caption);
        
$req = !empty($ele_req) ? 0;
        
$element->setVar('ele_req'$req);
        
$order = empty($ele_order) ? intval($ele_order);
        
$element->setVar('ele_order'$order);
        
$display = !empty($ele_display) ? 0;
        
$element->setVar('ele_display'$display);
        
$element->setVar('ele_type'$ele_type);

if (isset(
$_POST))
{
    foreach (
$_POST as $k => $v)
    {
        $
$k $v;
    } 


if (isset(
$_GET))
{
    foreach (
$_GET as $k => $v)
    {
        $
$k $v;
    } 
}

        switch(
$ele_type){
            case 
'text':
                
$value = array();
                
$value[] = !empty($ele_value[0]) ? intval($ele_value[0]) : $xoopsModuleConfig['t_width'];
                
$value[] = !empty($ele_value[1]) ? intval($ele_value[1]) : $xoopsModuleConfig['t_max'];
                
$value[] = $ele_value[2];
            break;
            case 
'textarea':
// snipped
            
break;
            case 
'areamodif':
// snipped
            
break;
            case 
'checkbox':
                
$value = array();
                while( 
$v each($ele_value) ){
                    if( !empty(
$v['value']) ){
                        if( 
$checked[$v['key']] == ){
                            
$check 1;
                        }else{
                            
$check 0;
                        }
                        
$value[$v['value']] = $check;
                    }
                }
            break;
            case 
'mail':
// snipped
            
break;
            case 
'mailunique':
// snipped
            
break;
            case 
'radio':
// snipped
            
break;
            case 
'yn':
// snipped
            
break;
            case 
'date':
                
$value = array();
                
$value[] = $ele_value;
            break;
            case 
'sep':
// snipped
            
break;
            case 
'select':
                
$value = array();
                
$value[0] = $ele_value[0]>intval($ele_value[0]) : 1;
                
$value[1] = !empty($ele_value[1]) ? 0;
                
$v2 = array();
                
$multi_flag 1;
                while( 
$v each($ele_value[2]) ){
                    if( !empty(
$v['value']) ){
                        if( 
$value[1] == || $multi_flag ){
                            if( 
$checked[$v['key']] == ){
                                
$check 1;
                                
$multi_flag 0;
                            }else{
                                
$check 0;
                            }
                        }else{
                            
$check 0;
                        }
                        
$v2[$v['value']] = $check;
                    }
                }
                
$value[2] = $v2;
            break;
            case 
'upload':
// snipped
            
break;
        }
        
$element->setVar('ele_value'$value);
        
$element->setVar('id_form'$id);
        if( !
$formulaire_mgr->insert($element) ){
            
xoops_cp_header();
            echo 
$element->getHtmlErrors();
        }else{
        
$url "index.php?id=$id";
        
Header("Location: $url");
        }
    break;

}
include 
'footer.php';
xoops_cp_footer();


function 
addOption($id1$id2$text$type='check'$checked=null){
// snipped
}

function 
addOptionsTray(){
// snipped
}
?>


I believe maybe the code is addressed to PHP4 and as I found out some constructs with arrays seems no longer to work in PHP5.
I am working with PHP 5.2.4 .
Is this code suffering from that problem? If yes, how should it be fixed, so it stays compatible with PHP4 and PHP5?

I have a programming background, but I am not deep enough in PHP to understand these finesses. (However the possibility remains that the cause of the problem is in a totaly different corner.)

Regards, Gerard.

7
ghia
Re: Formulaire Select Box problem
  • 2008/8/8 1:22

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


I tested Formulaire with the new XOOPS 2.3.0rc and this problem seems to be solved.
The XOOPS classes for formhandling has had a lot of modifications, which seems to resolve this select box configuration problem.
I will try to replace the class files for the XOOPS Form of my production systen 2.2.6 with these new ones.

Login

Who's Online

75 user(s) are online (39 user(s) are browsing Support Forums)


Members: 0


Guests: 75


more...

Donat-O-Meter

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

Latest GitHub Commits