Forum OpenACS Q&A: Re: Automatic list generation

Collapse
Posted by kousalya S on
Hi,

Here is my code to generate the list as what I have mentioned. But I need same form to display some columns in horizontal grid format and some in list format. Thing is I need dynfield feature to be included.

My code includes all the functions except one feature which embeds grid and list field view in same ad_form.

sample.tcl
#packages/sample/www/multiple3.tcl

ad_page_contract {

} {
sample_id:optional
{sample_nr: ""}
{end_date: ""}
{end_date_$i: ""}
{ticketnr_$i: ""}
ticketnr:array,optional
end_date:array,optional
{form_mode "edit" }
{number: ""}
}
#----------------------
#Defaults
#---------------------
set page_title ""
set user_id [ad_conn user_id]
set package_id [ad_conn package_id]
set ip_address [ad_conn peeraddr]

# ---------------------------------------------------------------
# Create the Form
# ---------------------------------------------------------------
set headers {Date TicketNr}
set title {Details}

set form_id "sample"
ad_form -name sample -mode $form_mode -form {
sample_id:key
{sample_nr:text(text),optional {label "Sample Nr" } }
{number:text(text) {html
{ onchange "document.sample.__refreshing_p.value='1';document.sample.submit()" } } }
}
# Add DynFields to the form
set my_sample_id 0
if {[info exists sample_id]} { set my_sample_id $sample_id }
im_dynfield::append_attributes_to_form \
    -object_type "im_sample" \
    -form_id $form_id \
    -object_id $my_sample_id

# ---------------------------------------------------------------
# Define Form Actions
# ---------------------------------------------------------------

ad_form -extend -name $form_id\

set date [list]
for {set i 1} {$i <= $number} {incr i} {

append date "
    {end_date_$i:text,optional
        {label \"End_Date #$i\"}
    }"
append date "
    {ticketnr_$i:text,optional
        {label \"TicketNr #$i\"}
    }"

}

ad_form -extend -name sample -form $date \

if { $i > 0 } {
    ad_form -extend -name sample -on_request {
        foreach name [array names date] {
            set $name $date($name)
        }
    } -on_submit {
        set task_revisions [list]
        for {set i 1} {$i <= $number} {incr i} {
      set sample_item_id [db_nextval "im_sample_items_seq"]
            set task_revisions [db_dml new_task_item "
            insert into im_sample
              ( sample_id, sample_item_id, type, ticketnr)
            values
              (:sample_id,:sample_item_id, :end_date_$i, :ticketnr_$i)"]
        }

    im_dynfield::attribute_store \
            -object_type "im_sample" \
            -object_id $object_id \
            -form_id $form_id
    } -select_query {
    select    s.*
      from im_sample s,
          acs_objects obj
      where s.sample_id = :object_id
      and obj.object_id = s.sample_id
      and obj.creation_user = :user_id
      and obj.context_id = :package_id

} -edit_data {
  # update the information on our table
  db_dml im_sample_update "
      update im_sample
        set  type=::end_date_$i, ticket_nr= :ticketnr_$i
where sample_item_id = :sample_item_id"

# update the last modified information on the object
  db_exec_plsql sample_form_obj_item_object_update {
      select acs_object__update_last_modified(:sample_id,:user_id,:ip_address)
  }
im_dynfield::attribute_store \
            -object_type "im_sample" \
            -object_id $object_id \
            -form_id $form_id
} -after_submit {
        ad_returnredirect multiple3
        ad_script_abort
    }
}

sample.adp
<master>
<property name="doc(title)">@page_title@</property>
<formtemplate id=sample style=wizard> </formtemplate>

Please do help me out!

Collapse
Posted by Jim Lynch on
OK, let me break this down... I see two parts to this...

Part 1, you say "I want to add feature xyz"

Part 2, you show the source

What's missing from part 1, is the work you've done to design the feature, its api and how you will invoke it from your code...

I'm not totally understanding yet what you're asking for... do you want help on a specific part of openacs you're not understanding? Or, do you want someone to literally do the work of building the site?

If you want to understand one specific piece, what is it?

If you want someone to come onboard to help you build the site, there is a lot of talent here that can help you, and suitable arrangements can be made, assuming you want to go in that direction.