Hi Brian,
below is a simple study that shows how to translate certain input tags in .adp pages (the example translates such tags into input tags of type 'text' with class "invisible"). I've tested this with plain NaviServer in an .adp page.
The OpenACS templating system is in some respects more tricky, since it has it own templating system on top of this for processing of the @-variables. It "compiles" such .adp file into low-level NaviServer pages and uses these later for delivery. So, when you add some tag definitions at runtime, there is no code that invalidates the already compiled pages.... that might be an explanation for the strange behavior you observed. .... so the best thing is to restart the server after adding tags.
all the best
-g
library script
namespace eval ::template {
proc tag-input {set} {
set attrs [ns_set array $set]
if {[dict exists $attrs type] && [dict get $attrs type] eq "hidden"} {
dict set attrs class hidden
dict set attrs type text
} else {
dict set attrs class visible
}
set output [join [lmap {k v} $attrs {set _ $k='$v'}] " "]
return "<input $output>"
}
}
ns_adp_registerscript input ::template::tag-input
page.adp
<!DOCTYPE html>
<html>
<body>
<form action="/action.tcl">
Name: <input type="text" name="fname"><br>
<input type="hidden" name="foo" value="bar">
<input type="submit" value="Submit">
</form>
page in browser:
<!DOCTYPE html>
<html>
<body>
<form action="/action.tcl">
Name: <input type='text' name='fname' class='visible'><br>
<input type='text' name='foo' value='bar' class='hidden'>
<input type='submit' value='Submit' class='visible'>
</form>