This forum is no longer open and is for reading/searching only.

Please use our new MachForm Community Forum instead.

MachForm Community Forums » MachForm 2

Clicking 'back' Button Removes Entered Data


  1. celica
    Member

    Clicking 'back' button on my review page deletes all single line text field data on the entry form (but paragraph text remains!).

    Is this a known issue? (perhaps I have a bug in my script) or can there be a workaround? Thanks for any help...

    Regards Alan Davies

    Posted 16 years ago #
  2. redityo

    Hi Alan,

    Hmmm It should get the data back, could you give me your form url and do some test on it?


    MachForm Support

    Posted 16 years ago #
  3. celica
    Member

    Hi redityo

    Thanks..... the url is

    http://www.essentialwebs.co.uk/whois/order.php

    Regards
    Alan

    Posted 16 years ago #
  4. redityo

    Hmmm It seems a session problem, could you try to put this code in the first line of your "order.php"

    <?php session_start(); ?>

    MachForm Support

    Posted 16 years ago #
  5. celica
    Member

    Hi Redito.

    I have tried the session code at the top of my order.php page, but unfortunately that doesn't change the scenario,

    NB I did edit the 'single line text' code in the "view-functions.php" file (from line 10) as below, in order to autofill element_37 single line text with a variable from my string.

    I would be most grateful if possible you could perhaps see a conflict with my code there...?

    //Single Line Text
    function display_text($element){

    //check for error
    $error_class = '';
    $error_message = '';
    $span_required = '';
    $guidelines = '';

    if(!empty($element->is_error)){
    $error_class = 'class="error"';
    $error_message = "<p class=\"error\">{$element->error_message}</p>";
    }

    //check for required
    if($element->is_required){
    $span_required = "<span id=\"required_{$element->id}\" class=\"required\">*</span>";
    }

    //check for guidelines
    if(!empty($element->guidelines)){
    $guidelines = "<p class=\"guidelines\" id=\"guide_{$element->id}\"><small>{$element->guidelines}</small></p>";
    }

    //post session url selected
    if($element->id == 37){
    $element->default_value = $_GET["domain"];
    }

    $element_markup = <<<EOT
    <li id="li_{$element->id}" {$error_class}>
    <label class="description" for="element_{$element->id}">{$element->title} {$span_required}</label>
    <div>
    <input id="element_{$element->id}" name="element_{$element->id}" class="element text {$element->size}" type="text" value="{$element->default_value}" />
    </div>{$guidelines} {$error_message}

  6. EOT;

    return $element_markup;
    }

    //Paragraph Text

    Regards
    Alan Davies

    NB apologies for my erroneous posts below:

Posted 16 years ago #
  • redityo

    I see ...I seems the problem come from this code :

    //post session url selected
    if($element->id == 37){
    $element->default_value = $_GET["domain"];
    }

    It will always set your text field in form 37 with "GET" variable and since you do not have GET variable in your URL when press a back button, It will filled with blank value.
    To fix it, try to replace those code with this one :

    if (($element->id == 37) && ($element->populated_value['element_'.$element->id]['default_value'] == '')){
    	$element->default_value = $_GET["domain"];
    }

    and I think you can consider to use a form id in your condition, so the code will be work on specific form only.


    MachForm Support

    Posted 16 years ago #
  • celica
    Member

    Thanks for taking the time to check and suggest a change to my edited code, redito, all is well again now.
    Regards
    Alan

    Posted 16 years ago #

  • RSS feed for this topic

    Reply