Login Retreive lost passwordRegister
Search

Forum Index / General / setErrorMessage giving invalid output

[ This topic is solved ]

  xymod 14 April 10 / 13:29  
Hi - great tool and I am starting to get my head around it, but I have run into an issue that seems to invalidate my html when using setErrorMessage

In your example
$form -> setErrorMessage( "fname", "You have to enter a first name!");
my output code would look like this
<span id="error_Array" class="error" >You have to enter a first name!</span>

The issue is with the span's id ="error_Array". If I use setErrorMessage elsewhere the new error message is also returned with an id="error_Array", which is invalid markup, and makes it hard to css style individual error messages.

Any ideas?
Thanks

  xymod 14 April 10 / 13:30  
Sorry just noticed the post 'bug in mask error "error_Array"' - might be the same issue?

  Johan Wiegel (Admin) 14 April 10 / 13:34  
can you post some code where this problem exists?

I cannot reproduce this.

  xymod 14 April 10 / 13:54  
Here you go - this is a shorter than my full form, but still gives me the the issue with both <span> id's = "error_Array".

<?php
// include the class
include('../php/formhandler/class.FormHandler.php');
// make a new $form object
$form = new FormHandler();
$star ' <em class="importStar">*</em>'
$form->enableAjaxValidatortrue );
// noTables
$form -> useTable(false); 
// add a line that every field with a red * is required
$form -> addLine("<p>".$star ."  = Required fields</p>");
$form->textField("What".$star"what"FH_STRING,50,100);
$form -> setErrorMessage"what""Please enter a valid event title!");
$form->textField("Where".$star"where"FH_STRING,50,100);
$form -> setErrorMessage"where""Please enter a valid event address!");
// submitbutton beneath it
$form->submitButton("Submit");
// set the 'commit after form' function
$form->onCorrect("doRun");
// send the form to the screen
$form->flush();
// function to show a message
function doRun($data)
{
return 
"Thankyou "$data["name"];
}

?>

  xymod 14 April 10 / 14:52  
Just to provide a bit more info-
php version used: 5.1.6

  Johan Wiegel (Admin) 14 April 10 / 15:12  
Found the bug and solved it.

Please download the zip again. (only class.formhandler.php is changed)

  xymod 14 April 10 / 16:11  
Excellant - yes that makes complete sense (I looked at the code but missed that!) The id's are working again. Many thanks for that

  Top


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