I've got a system that automatically generates a form. I have it set
up so that the backend will return to the inital form page with an
error object in sessions data (assuming the backend detected invalid
data or required fields not filled in) and the frontend will generate
an initial value of items WITHOUT errors (so the user doesn't have to
reenter valid info).
This is the problem. The frontend generates the initial value
attribute 'value="(<field _name_here>)"', so if the field's name was
'Phone' it would generate 'value="(Phone) "' instead of
'value="555-555-5555"'.
I've checked what the POST method is sending the backend, and it's ok.
I also checked what the backend is sending the frontend through the
session varialbes, and it's ok too. So my only thought is it's either
somewhere in the code or it's MSIE 6.
Here's the code
It is based upon 3 objects:
1) fieldArray - matrix associative array of all fields of the form and
eache fields properties (ie. type, name, initial value, etc)
2) error->errorArray - array in error class with the names of each
error producing field (ie. required field not filled in, fields with
invalid data, etc.)
3) error->hasErrors - boolean, true if there are errors in errorArray
4) 3 objects (account,order, signup) each with an array of data from the
user (eventually put into mySQL db)
NOTE: this is in a foreach statement that walks the fieldArray
-----PHP Code-----
//check for type, if text, do this...
elseif($fieldAr ray[type] == 'text') {
//begin input element
$_element = "<input type=\"text\" name=\"$fieldAr ray[name]\" ";
//check for errors - if there are errors, but this field isn't in
// the list of fields with errors, do this...
if($error->hasErrors() &&
array_search($f ieldArray[name],$error->getErrorArray( ))==false) {
//if data is in the account object, add the value attribute to
// the input field with the value from the object as the
// attribute value
//NOTE: the getField functions return false if the field isn't
// found, they return the value of the field if it is found
if($account->getField($fiel dArray[name]) != false) {
$_element .= "value=\"$accou nt->getField($fiel dArray[name])\" ";
}
//if data is in the orderobject, add the value attribute to
// the input field with the value from the object as the
// attribute value
elseif($order->getField($fiel dArray[name]) != false) {
$_element .= "value=\"$o rder->getField($fiel dArray[name])\" ";
}
//if data is in the signupobject, add the value attribute to
// the input field with the value from the object as the
// attribute value
elseif($signup->getField($fiel dArray[name]) != false) {
$_element .= "value=\"$signu p->getField($fiel dArray[name])\" ";
}
}
// finish the input field
$_element .= '/>';
}
-----PHP Code-----
Thanks for taking a look at this,
-TekWiz
up so that the backend will return to the inital form page with an
error object in sessions data (assuming the backend detected invalid
data or required fields not filled in) and the frontend will generate
an initial value of items WITHOUT errors (so the user doesn't have to
reenter valid info).
This is the problem. The frontend generates the initial value
attribute 'value="(<field _name_here>)"', so if the field's name was
'Phone' it would generate 'value="(Phone) "' instead of
'value="555-555-5555"'.
I've checked what the POST method is sending the backend, and it's ok.
I also checked what the backend is sending the frontend through the
session varialbes, and it's ok too. So my only thought is it's either
somewhere in the code or it's MSIE 6.
Here's the code
It is based upon 3 objects:
1) fieldArray - matrix associative array of all fields of the form and
eache fields properties (ie. type, name, initial value, etc)
2) error->errorArray - array in error class with the names of each
error producing field (ie. required field not filled in, fields with
invalid data, etc.)
3) error->hasErrors - boolean, true if there are errors in errorArray
4) 3 objects (account,order, signup) each with an array of data from the
user (eventually put into mySQL db)
NOTE: this is in a foreach statement that walks the fieldArray
-----PHP Code-----
//check for type, if text, do this...
elseif($fieldAr ray[type] == 'text') {
//begin input element
$_element = "<input type=\"text\" name=\"$fieldAr ray[name]\" ";
//check for errors - if there are errors, but this field isn't in
// the list of fields with errors, do this...
if($error->hasErrors() &&
array_search($f ieldArray[name],$error->getErrorArray( ))==false) {
//if data is in the account object, add the value attribute to
// the input field with the value from the object as the
// attribute value
//NOTE: the getField functions return false if the field isn't
// found, they return the value of the field if it is found
if($account->getField($fiel dArray[name]) != false) {
$_element .= "value=\"$accou nt->getField($fiel dArray[name])\" ";
}
//if data is in the orderobject, add the value attribute to
// the input field with the value from the object as the
// attribute value
elseif($order->getField($fiel dArray[name]) != false) {
$_element .= "value=\"$o rder->getField($fiel dArray[name])\" ";
}
//if data is in the signupobject, add the value attribute to
// the input field with the value from the object as the
// attribute value
elseif($signup->getField($fiel dArray[name]) != false) {
$_element .= "value=\"$signu p->getField($fiel dArray[name])\" ";
}
}
// finish the input field
$_element .= '/>';
}
-----PHP Code-----
Thanks for taking a look at this,
-TekWiz
Comment