Autofilled PHP Forms
Subject:   Problem with using array input names
Date:   2006-07-11 00:21:32
From:   sdave1284
Response to: Problem with using array input names

Well, I don't use it everywhere. I only use it for text fields. So I made the following addition to fillInInputTag()(Note: i'm not very experienced with the best solutions to these problems, nor do I use regular expressions often):

$num_of_matches = preg_match("/([\w]+)(\W([\d]+)\W)/", $name, $name_match);

$name_arr = $name_match[1];
$name_index =$name_match[3];

if($num_of_matches == 0) {
if (!array_key_exists($name, $this->request))
return $tag;
return fillInFormHelper::replaceAttributeVal($tag, 'value', $this->request[$name]);
} else {
if (!array_key_exists($name_arr, $this->request))
return $tag;

return fillInFormHelper::replaceAttributeVal($tag, 'value', $this->request[$name_arr][$name_index]);

In my input names, I add a index number instead of just using name[]. I think this gives me better control, plus I can use the above method to fill in the text fields. Now, I just need to figure out how to do the same thing for the validateForm function....

Your scripts have made me life creating version 2 of our website 100X easier. Expansion will be much easier as new fields are added to the forms and database backend! Thanks and feel free to comment on what I did above...