| Article: |
Autofilled PHP Forms | |
| Subject: | Problem with using array input names | |
| Date: | 2006-07-07 16:12:06 | |
| From: | GavinAndresen | |
|
Response to: Problem with using array input names
|
||
|
I was wondering when somebody would notice that it doesn't handle PHP's built-in support for arrays of form fields.
|
||
Showing messages 1 through 1 of 1.
-
Problem with using array input names
2006-07-11 00:21:32 sdave1284 [View]



$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...
Dave