Index: openacs-4/packages/acs-core-docs/www/form-builder.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-core-docs/www/form-builder.adp,v diff -u -r1.4.2.4 -r1.4.2.5 --- openacs-4/packages/acs-core-docs/www/form-builder.adp 26 Aug 2020 07:46:25 -0000 1.4.2.4 +++ openacs-4/packages/acs-core-docs/www/form-builder.adp 3 Sep 2021 09:15:00 -0000 1.4.2.5 @@ -1,5 +1,5 @@ -{/doc/acs-core-docs {ACS Core Documentation}} {Using Form Builder: building html forms dynamically} +{/doc/acs-core-docs/ {ACS Core Documentation}} {Using Form Builder: building html forms dynamically} Using Form Builder: building html forms dynamically Multi-part Elements

Some elements have more than one choice, or can submit more than one value.

-SELECT elements

  1. +SELECT elements
  1. Creating the form element. Populate a list -of lists with values for the option list.

    -set foo_options [db_list_of_lists foo_option_list "
    +of lists with values for the option list.

    set foo_options [db_list_of_lists foo_option_list "
         select foo,
                foo_id
           from foos
    @@ -54,8 +53,7 @@
     refreshes to pull additional information from the database

A situation you may run into often is where you want to pull in form items from a sub-category when the first category is selected. Ad_form makes this fairly easy to do. In the definition of your -form element, include an HTML section

-{pm_task_id:integer(select),optional
+form element, include an HTML section

    {pm_task_id:integer(select),optional
         {label "Subject"}
         {options {$task_options}}
         {html {onChange "document.form_name.__refreshing_p.value='1';submit()"}}
@@ -64,8 +62,7 @@
     

What this will do is set the value for pm_task_id and all the other form elements, and resubmit the form. If you then include a block that extends the form, you'll have the opportunity to add -in subcategories:

-if {[info exists pm_task_id] && $pm_task_id ne ""} {
+in subcategories:

    if {[info exists pm_task_id] && $pm_task_id ne ""} {
     db_1row get_task_values { }
     ad_form -extend -name form_name -form { ... }
     

Note that you will get strange results when you try to set the @@ -99,7 +96,7 @@ Errors

Here are some common errors and what to do when you encounter them:

-Error when selecting values

This generally happens when there is an error in your query.

+Error when selecting values

This generally happens when there is an error in your query.