Index: openacs-4/contrib/packages/classified-ads/www/admin/field-addedit.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/classified-ads/www/admin/field-addedit.tcl,v
diff -u -N -r1.1 -r1.2
--- openacs-4/contrib/packages/classified-ads/www/admin/field-addedit.tcl 16 Jul 2003 04:52:32 -0000 1.1
+++ openacs-4/contrib/packages/classified-ads/www/admin/field-addedit.tcl 29 Jul 2003 02:03:09 -0000 1.2
@@ -14,9 +14,13 @@
{default_value:nohtml ""}
{widget:nohtml text}
{label:nohtml ""}
+ {keyword_id:integer ""}
{html_options:nohtml ""}
{select_options:nohtml ""}
{validate:nohtml ""}
+ {extra_help_p:boolean t}
+ {extra_help_text ""}
+ {extra_format ""}
{optional_p:boolean f}
{enabled_p:boolean t}
} -properties {
@@ -54,13 +58,14 @@
template::element create new_field attribute_name \
-datatype text \
-label "Attribute Name" \
- -help "A-Z, a-z, 0-9, - and _ only" \
+ -help_text "A-Z, a-z, 0-9, - and _ only" \
-html "size 30 $cant_edit_html" \
-value $attribute_name
template::element create new_field pretty_name \
-datatype text \
-label "Pretty Name" \
+ -help_text "These (with Pretty Plural) are the names you'll know this field by (see Label)" \
-html "size 30" \
-value $pretty_name
@@ -75,13 +80,15 @@
-datatype text \
-label "Datatype" \
-html $cant_edit_html \
+ -help_text "The kind of value you want" \
-options [db_list_of_lists datatypes { }] \
-value $datatype
template::element create new_field column_spec \
-datatype text \
-label "Column Spec" \
-html $cant_edit_html \
+ -help_text "The SQL data type of the column you want created in the database. Value in column spec must agree with value in datatype. e.g. integer
, varchar(100)
, timestamp
, numeric(9,2)
, etc." \
-value $column_spec
if { $sort_order == "" } {
@@ -93,18 +100,21 @@
-datatype integer \
-label "Sort Order" \
-html "size 5" \
+ -help_text "The order in the form (top-to-bottom) you want this field displayed in." \
-value $sort_order
template::element create new_field default_value \
-datatype text \
-label "Default Value" \
-html "size 30" \
+ -help_text "If the user enters no value, this will be used as default." \
-value $default_value
template::element create new_field widget \
-widget select \
-datatype text \
-label "Widget" \
+ -help_text "How would you like the data entry field displayed?" \
-html $cant_edit_html \
-options [db_list_of_lists widgets { }] \
-value $widget
@@ -113,45 +123,98 @@
-datatype text \
-label "Label" \
-html {size 30} \
+ -help_text "This is the word that appears beside the field on the place ad form shown to users." \
-value $label
template::element create new_field html_options \
-datatype text \
-label "HTML Options" \
-html {size 30} \
+ -help_text "For additional HTML attributes for the widget. Always surround with {braces} and always in attribute value order. e.g. {size 30 maxlength 100 onfocus \"blur();\"}
" \
-value $html_options
template::element create new_field select_options \
-datatype text \
-label "Select Options" \
-html {size 30} \
+ -optional \
+ -help_text "A list of options for select lists and button groups (check boxes or radio buttons). The list contains two-element lists in the form { {label value} {label value} {label value} ...}
e.g. {{S \"12.99\"} {M \"15.49\"} {L \"17.99\"}}
renders in HTML:
+ <option value=\"12.99\">S + <option value=\"15.49\">M + <option value=\"17.99\">L +" \ -value $select_options +template::element create new_field extra_format \ + -widget select \ + -datatype text \ + -label "Format for Dates" \ + -help_text "If the datatype is \"date\", this is the order of the date fields that will be shown to the user." \ + -options {{"Month/Day/Year" "MONTH DD YYYY"} {"Day/Month/Year" "DD MONTH YYYY"} {"Year/Month/Day" "YYYY MONTH DD"} {"Year/Day/Month" "YYYY DD MONTH"}} \ + -value $extra_format + +template::element create new_field extra_help_text \ + -datatype text \ + -label "Help Text" \ + -html {size 30} \ + -optional \ + -help_text "Whatever you enter here will be shown to the user under the field. Use it to give helpful hints to the user about what he should enter." \ + -value $extra_help_text + template::element create new_field validate \ -datatype text \ -label "Validate" \ + -optional \ -html {size 30} \ + -help_text "(experts only) — A list of custom validation blocks in the form
{ name { expression } { message } name { expression } { message } ...}
where name is a unique identifier for the validation step, expression is a block to Tcl code that evaluates to 1 or 0, and message is to be displayed to the user when the validation step fails. Use the special variable \$value to refer to the value entered by the user in that field." \
-value $validate
+template::element create new_field extra_help_p \
+ -datatype boolean \
+ -widget checkbox \
+ -options {{"Show Date Help" t}} \
+ -label " " \
+ -optional \
+ -help_text "If the field is of datatype \"date\" and this is checked, the month, day, year fields will be labeled." \
+ -value $extra_help_p
+
template::element create new_field optional_p \
-datatype boolean \
-widget checkbox \
-label " " \
-options {{Optional t}} \
+ -help_text "If checked, the user won't be required to use this field." \
-value $optional_p
template::element create new_field enabled_p \
-datatype boolean \
-widget checkbox \
-label " " \
+ -help_text "If checked, this field will appear to the user." \
-options {{Enabled t}} \
-value $enabled_p
if [template::form is_valid new_field] {
set user_id [ad_conn user_id]
set peeraddr [ad_conn peeraddr]
+ set extra_options ""
+
+ if {[string match $datatype "date"]} {
+ if {![empty_string_p $extra_help_p]} {
+ append extra_options " -help"
+ }
- ns_log Notice "RIGHT HERE"
+ if {![empty_string_p $extra_format]} {
+ append extra_options " -format $extra_format"
+ }
+ }
+
+ if {![empty_string_p $extra_help_text]} {
+ append extra_options " -help_text \""
+ append extra_options $help_text
+ append extra_options "\""
+ }
+
if [info exists attribute_id] {
db_transaction {
db_dml attribute_update { }