Login Retreive lost passwordRegister
Search

Forum Index / General / setValue and $bOverwriteCurrentValue bug ?

[ This topic is solved ]

  kreatik 06 May 09 / 01:56  
Hi all :)

Try this :

1) In a form with multiple page, set a default value with setValue(),
2) run the form, modify this value and go to the next page of form
3) use previous button for return to previous page of form and you can view of value of element is the default value !

You confirm this ?

  Johan Wiegel (Admin) 06 May 09 / 07:59  
Changed at 06 May 09 / 07:59
no, i can't confirm this.
I used the following code:

<?php
$oForm 
= new FormHandler'test');
$oForm->SetValue'test''default' );

$oForm->TextField'test''test'null,null,null,'' );
$oForm->submitButton'Next page' );

$oForm->newPage();
$oForm->TextField'test''test2'null,null,null,'' );
$oForm->backButton('Back');
$oForm->submitButton'submit' );

$oForm->onCorrect('FH_RUN');
$oForm->flush();
?>


in the first page altered default to defaultdd, pressed "Next page"
altered field in second page en pressed "Back" value was defaultdd

I used FF2 AND IE7 as my browsers to test this

  kreatik 06 May 09 / 10:07  
In the manual : "This function works on all fields! It does not matter if you call this function before or after the declaration of a field."

Try this (after the declaration of the field) :


$oForm->TextField( 'test', 'test', null,null,null,'' );

$oForm->SetValue( 'test', 'default' );
$oForm->submitButton( 'Next page' );

$oForm->newPage();
$oForm->TextField( 'test', 'test2', null,null,null,'' );
$oForm->backButton('Back');
$oForm->submitButton( 'submit' );

$oForm->onCorrect('FH_RUN');
$oForm->flush();

  Johan Wiegel (Admin) 06 May 09 / 10:14  
Changed at 06 May 09 / 10:15
so it's a bug in the manual ;)
needs to be placed before the field in order to keep the altered value in a multipage form.

  kreatik 07 May 09 / 00:26  
Changed at 07 May 09 / 09:51
hi,
I am again after long hours of research about my problem and here is my conclusion: you can not assign a value to an element after the first loading of the page.

For example if you want to select items on the page 2 depending on the choice of page 1 of this form does not work :(

Try this :

<?php
$choices
=array(
    
'opt'=>array(
        
1,2,3,4
    
),
    
'tab2'=>array(
        
4=>'t2_v1',
        
1=>'t2_v2',
        
2=>'t2_v3',
        
3=>'t2_v4'
    
)
);

require 
'inc/FH3/class.FormHandler.php';
$oForm = new FormHandler();
$oForm->selectField('choose','choose',$choices['opt'],null,false);
$oForm->submitButton'Next page' );

$oForm->newPage();

if(
$oForm->getValue('choose')!=null){
    
$oForm->setValue'confirm',  $oForm->getValue('choose'));// NOT WORKING !
}

$oForm->selectField'please confirm''confirm'$choices['tab2']);
$oForm->backButton('Back');
$oForm->submitButton'submit' );

$oForm->onCorrect('FH_RUN');
$oForm->flush();


function 
FH_RUN(){
    return 
true;
}
?>

  Johan Wiegel (Admin) 07 May 09 / 07:55  
Changed at 07 May 09 / 10:17
This seems to work:
<?
$choices
=array(
    
'opt'=>array(
        
1,2,3,4
    
),
    
'tab2'=>array(
        
4=>'t2_v1',
        
1=>'t2_v2',
        
2=>'t2_v3',
        
3=>'t2_v4'
    
)
);
;
$oForm = new FormHandler();
$oForm->selectField('choose','choose',$choices['opt'],null,false);
$oForm->submitButton'Next page' );

$oForm->newPage();

if(
$oForm->getValue('choose')!=null){
    
$oForm->AddLine$oForm->getValue('choose') );
    
$oForm->setValue'confirm',  $oForm->getValue('choose'), true);// select : tX_v3        IS WORKING I ADDED A PARAMETER TRUE!
}


$oForm->selectField'please confirm''confirm'$choices['tab2']);
$oForm->backButton('Back');
$oForm->submitButton'submit' );

$oForm->onCorrect('FH_RUN');
$oForm->flush();
?>

  kreatik 07 May 09 / 09:55  
Please read my question, interest does not display the value, but to select a element an page 2 according to the selection on page 1.

  Johan Wiegel (Admin) 07 May 09 / 10:16  
Please take a good look at my code, I added a parameter true to make it work

  kreatik 07 May 09 / 13:39  
I just tried your setting, but the choices are not retained if you go to the next page and you return to the previous page.

  Johan Wiegel (Admin) 07 May 09 / 13:44  
Changed at 07 May 09 / 13:44
please try at this url: http://www.jwiegel.com/FH/test.php

tell me exactly what you choose what you see in the next page, what you expect to see in the pages etc.

as far as I can see in the code the form behaves like it should if I look at the code.

It's possible I don't understand what you mean ;)

  kreatik 07 May 09 / 13:50  
Changed at 07 May 09 / 13:56
please view this video : http://rapidshare.com/files/230186100/testForm.wmv.html

<?php

$oForm 
= new FormHandler();
$oForm->selectField('choose a number for next step','choose',$choices['opt'],null,false);
$oForm->submitButton'Next page' );

$oForm->newPage();

if(
$oForm->getValue('choose')!=null){
    
$oForm->setValue'confirm',  $oForm->getValue('choose'),true);
}

$oForm->selectField'please confirm''confirm'$choices['tab2']);
$oForm->backButton('Back');
$oForm->submitButton'Next page' );

$oForm->newPage();
$oForm->addHTML('sdinfsdion');
$oForm->backButton('Back');
$oForm->submitButton'submit' );

$oForm->onCorrect('FH_RUN');
$oForm->flush();

?>

  Johan Wiegel (Admin) 07 May 09 / 14:05  
Changed at 07 May 09 / 14:05
so you did introduce a third page you never mentioned that ;)

  Johan Wiegel (Admin) 07 May 09 / 14:11  
try this:

<?php
$oForm 
= new FormHandler();
$oForm->HiddenField'third_page');
$oForm->selectField('choose a number for next step','choose',$choices['opt'],null,false);
$oForm->submitButton'Next page' );

$oForm->newPage();


$oForm->selectField'please confirm''confirm'$choices['tab2']);

if( 
$oForm->getValue'third_page' ) == )
{
    
$oForm->setValue'confirm',  $oForm->getValue('choose'),true);
}

$oForm->backButton('Back');
$oForm->submitButton'Next page' );

$oForm->newPage();
$oForm->SetValue'third_page');
$oForm->addHTML('sdinfsdion');
$oForm->backButton('Back');
$oForm->submitButton'submit' );

$oForm->onCorrect('FH_RUN');
$oForm->flush();
?>

  kreatik 07 May 09 / 21:54  
no it does not work: (

  Johan Wiegel (Admin) 07 May 09 / 22:46  
my test situation does exactly what your video describes.

what goes wrong???

  Top


powered by PHP-GLOBE   © 2004 - 2010 FormHandler. All rights reserved.   -   Open source license