Bug: Formatted Search uses title but should use name for formfield parameter
documenation for
FormattedSearch says $formfield(name) but actually uses $formfield(title). Should use the meta field name.
Test case
The documentation for
FormattedSearch is a bit inaccurate for $formfield(name). In fact the code picks up $formfield(title). This can be a problem if the title is not a
WikiWord. For example, in the case I was working on, I find the following META tags at the bottom of the topic file:
META:FORM{name="BuyerForm"}%
META:FIELD{name="BuyerType" title="BuyerType" value="ComputerHardwareMfg, TeleCom"}%
META:FIELD{name="Region" title="[[Region]]" value="NorthAmericaRegion"}%
META:FIELD{name="CompanyRevenue2002MilUS" title="Company Revenue 2002 (Mil US$)" value="18915"}%
META:FIELD{name="CompanyRevenue2001MilUS" title="Company Revenue 2001 (Mil US$)" value="21790"}%
This works (clumsily) for something like
$formfield([[Region]])
But blows everything up if you use the more complex
$formfield(Company Revenue 2002 (Mil US$))
I think it would be better to use the "name" field above, so that the documentation is correct. It is probably generally improper to use the title of the META field for processing. To fix this, make the following minor change in
Search.pm:
sub getMetaFormField
...snip...
$title = $field->{"title"}; # should change to $title = $field->{"name"};
$value = $field->{"value"};
$value =~ s/^\s*(.*?)\s*$/$1/go;
if( $title eq $name ) {
$value = breakName( $value, $break );
return $value;
--
RaymondLutz - 17 Oct 2003
Environment
--
RaymondLutz - 17 Oct 2003
Follow up
Fix record
You are right about the usefulness of name vs title. I could not simply change from title to name because this would break existing applications that assume title. So I fixed it to look for name and title, this makes it behave the way users expect, and also should not break existing apps.
Change:
Index: Search.pm
===================================================================
--- Search.pm (revision 1590)
+++ Search.pm (working copy)
@@ -1124,14 +1124,12 @@
$name = $params[0] || "";
$break = $params[1] || 1;
}
- my $title = "";
my $value = "";
my @fields = $theMeta->find( "FIELD" );
foreach my $field ( @fields ) {
- $title = $field->{"title"};
$value = $field->{"value"};
$value =~ s/^\s*(.*?)\s*$/$1/go;
- if( $title eq $name ) {
+ if( $name =~ /^($field->{"name"}|$field->{"title"})$/ ) {
$value = breakName( $value, $break );
return $value;
}
Change is in
SVN.
--
PeterThoeny - 23 Jul 2004