- Methods: All Methods Documented Methods Hide Methods
- Source: Display Source Hide Source
- Variables: Show Variables Hide Variables
Class ::Generic::Form
::Generic::Form create ... \
[ -action (default "[::xo::cc url]") ] \
[ -add_page_title add_page_title ] \
[ -data data ] \
[ -edit_page_title edit_page_title ] \
[ -fields fields ] \
[ -folder_id (default "-100") ] \
[ -html (default "") ] \
[ -name (default "[namespace tail [self]]") ] \
[ -package_id (default "") ] \
[ -submit_link (default ".") ] \
[ -validate (default "") ] \
[ -with_categories (default "false") ]
Defined in
Class Relations
::xotcl::Class create ::Generic::Form \ -superclass ::xotcl::ObjectMethods (to be applied on instances)
generate (scripted, public)
<instance of Generic::Form> generate [ -template template ] \ [ -mode mode ] [ -export export ]The method generate is used to actually generate the form template from the specifications and to set up page_title and context when appropriate.
- Switches:
- -template (optional, defaults to
"formTemplate"
)- is the name of the Tcl variable to contain the filled in template
- -mode (optional, defaults to
"edit"
)- -export (optional)
- list of attribute value pairs to be exported to the form (nested list)
- Testcases:
- xowiki_test_cases
# set form name for adp file set :$template ${:name} set object_type [[${:data} info class] object_type] set object_name [expr {[${:data} exists name] ? [${:data} set name] : ""}] # :log "-- ${:data}, cl=[${:data} info class] [[${:data} info class] object_type]" #:log "--e ${:name} final fields ${:fields}" set exports [list [list object_type $object_type] [list folder_id ${:folder_id}] [list __object_name [::security::parameter::signed $object_name]]] if {[info exists export]} { foreach pair $export {lappend exports $pair} } ad_form -name ${:name} -form ${:fields} -mode $mode -export $exports -action [:action] -html [:html] #:log "--- generate: setup methods on data ${:data}" set new_data "set item_id \[[self] new_data\]" set edit_data "set item_id \[[self] edit_data\]" set new_request "[self] new_request" set edit_request "[self] edit_request \$item_id" set after_submit "[self] after_submit \$item_id" set on_validation_error "[self] on_validation_error" set on_submit "[self] on_submit \$item_id" if {[:with_categories]} { set coid [expr {[${:data} exists item_id] ? [${:data} set item_id] : ""}] category::ad_form::add_widgets -form_name ${:name} -container_object_id ${:package_id} -categorized_object_id $coid # When editing, fill category form widgets # with current mappings for this object append edit_request { category::ad_form::fill_widgets -container_object_id ${:package_id} -categorized_object_id $item_id } append new_data { category::map_object -remove_old -object_id $item_id $category_ids } append edit_data { category::map_object -remove_old -object_id $item_id $category_ids } append on_submit { set category_ids [category::ad_form::get_categories -container_object_id ${:package_id}] } } #ns_log notice "-- ad_form new_data=<$new_data> edit_data=<$edit_data> edit_request=<$edit_request>" # # Action blocks must be added last. "-new_data" and "-edit_data" # are enclosed in a transaction, such that optional additional # code from category management is executed safely # ad_form -extend -name ${:name} -validate [:validate] -new_data "xo::dc transaction \{ $new_data \}" -edit_data "xo::dc transaction \{ $edit_data \}" -on_submit $on_submit -new_request $new_request -edit_request $edit_request -on_validation_error $on_validation_error -after_submit $after_submitVariables
::Generic::Form set __default_metaclass ::xotcl::Class ::Generic::Form set __default_superclass ::xotcl::Object
- Methods: All Methods Documented Methods Hide Methods
- Source: Display Source Hide Source
- Variables: Show Variables Hide Variables