xowf::test_item::Renaming_form_loader method rename_attributes (public)

 <instance of xowf::test_item::Renaming_form_loader[i]> rename_attributes \
    form_obj

Defined in packages/xowf/tcl/test-item-procs.tcl

Perform attribute renaming in the provided form_obj and return this form_obj. In essence, this changes the generic "@answer@" value in the form and in the form constraints to a name based on the form name.

Parameters:
form_obj (required, object)

Testcases:
No testcase defined.
Source code:
set form [$form_obj get_property -name form]
set fc   [$form_obj get_property -name form_constraints]

#
# Map "answer" to a generic name "@answer@" in the form and in
# the form constraints.
#
set newName [:form_name_based_attribute_stem [$form_obj name]]
#ns_log notice "renaming form loader: MAP '[$form_obj name]' -> '$newName'"

regsub -all -- {@answer} $form @$newName form
set fc [:map_form_constraints $fc "answer" $newName]
set disabled_fc [lmap f $fc {
  if {[string match "$newName*" $f]} { append f ,disabled=true }
  set f
}]

lappend fc @cr_fields:hidden
lappend disabled_fc @cr_fields:hidden
#:msg fc=$fc

$form_obj set_property -new 1 form $form
$form_obj set_property -new 1 form_constraints $fc
$form_obj set_property -new 1 disabled_form_constraints $disabled_fc

#ns_log notice "RENAMED form $form\n$fc\n$disabled_fc"
return $form_obj
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: