[ic] workaround for bug in error tag

Bill Randle billr@exgate.tek.com
Wed, 25 Oct 2000 11:54:04 -0700

On Oct 25,  7:57am, Guido Sohne wrote:
} Subject: workaround for bug in error tag
} I did some digging around in the mail archives and
} found someone (Bill Randle) who had not only had the
} same problem but suggested a workaround ...
} The URL for the archive of his post is at
} http://www.minivend.com/pipermail/interchange-users/2000-October/001143.html

I'm glad you found that. I was looking to see if I had saved a copy of
that message when I saw your posting, but I didn't find it.

} This seems to be something a lot of people will
} eventually run into (and not just developers too)!
} His post says this bug has been around for over a
} year. If a fix is too difficult or requires
} restructuring of too much code, why not document the
} workaround or move the construct demo to a different
} model for error checking such as that suggested by Mr
} Randle ?
} Why not fix it now ? Over a year for an error in code
} that is supposed to check for errors seems a bit
} excessive ...

Well, it is and it isn't a bug - depending on your perspective.
All the "required=1" option on the [error] tag does is put
the label in bold font so you can say "Required fields are in
bold" at the top of the page. It doesn't do any checking for
empty field contents.

If the session error hash for the particular variable is not empty
(e.g. $Vend::Session->{errors}{day_phone}), then it prints the
error text in red. You are required to see that the error hash
gets filled in with something when the field is empty.

There are three ways to do this:
	1. let [userdb new_account] do it, which it will do for
	   certain fields, such as userid and password,

	2. let the order routing do it, which it will do for name
	   listed as required in etc/order.profiles, or in an
	   inline mv_click/mv_check - if creating the new account
	   triggers the order process.

	3. do it yourself, which is what I've done in several instances,
	   as I wanted the user to create an account *before* placing
	   an order.

It's something I've had to do often enough (for 3 sites now), I think
it would be a nice feature to add to IC. Perhaps this could be done
by extending the mv_click processor to pickup the &var=required
lines and check $CGI->{var} locally (preferably using the filters,
as well) and set the error hash. I.e., pull the check functionality
currently only available as part of the order routing and move that
out to be a more globally accessable/useable function.