Forum OpenACS Q&A: an example with ad_form - newbie question

The first question:

I am following the example from documentation for “ad_form” function. My code looks like:

ad_page_contract {
        Simple add/edit form for d-bug.
} {
    dbug_id:integer,optional
}
set user_id [ad_maybe_redirect_for_registration]
set title "Add a D-Bug"

if {[exists_and_not_null dbug_id]} {
    set title "Edit a D-Bug"
}

ad_form -name d-bug -form {
    dbug_id:key(dbg_dbg_id_sq)
    {component:integer
        {label "Component"}
    }
    {sumary:text(textarea)
        {label "Title"}
    }
    {version_found:integer
        {label "Ver.Found"}
    }
    {version_willfix:integer
        {label "Ver. Will Fix"}
    }
    {version_didfix:integer
        {label "Ver. Did Fix"}
    }
    {description:text(textarea)
        {label "Summary"}
    }
} -select_query {
    SELECT *
    FROM  d_bug
    WHERE  dbug_id = :d_bug_id
} -new_data {

db_dml do_insert "
      INSERT INTO d_bug
      VALUES      (
                  :dbug_id,
                  :component,
                  :sumary,
                  :version_found,
                  :version_willfix,
                  :version_didfix,
                  :description
                  )
"
} -edit_data {
db_dml do_update "
      UPDATE d_bug
      SET    component      = :component,
              sumary          = :sumary,
              version_found  = :version_found,
              version_willfix = :version_willfix,
              version_didfix  = :version_didfix,
              description    = :description
      WHERE  dbug_id        = :key"
} -after_submit {
ad_returnredirect "index"
}

While inserting a new bug works ok, when I click on edit, I have this error message:

Not Found
The requested URL was not found on this server.

And this is the link in browser:
http://192.x.x.114:8000/d-bug/d_bug-edit?dbug_id=1

If anyone is willing to give an advice, or need more information, please ask.

My second question is how to use custom “default-master.adp” for only one package? I assume, that if I adjust default-master.adp, all packages will change, not just my testing package.

Thank you for your time.

DanielD

Collapse
Posted by Don Baccus on
when I click on edit, I have this error message
So where is this link you're clicking on, in your index template? And what is the name of your form-handling file? My guess is that that you've just got the URL wrong in the hyperlink referencing the form-handling file.

As for your second question ... look-and-feel is modifiable for individual subsites, not individual packages. We do things this way because commonly people want to give a site a uniform look-and-feel and this simplifies the amount of customization needed to accomplish this.

So what you'd need to do to change the look-and-feel of your testing package is to mount another instance of acs-subsite in the site-map, give that acs-subsite instance its own master template, then mount your test package under the new acs-subsite instance.

This assumes you write your package in the generalized style we use. If your package is customized for a particular website and will never be used outside that particular website there's no reason you can't define a master template in your package then refer to it directly in the "master" tag within your various content pages.

Collapse
Posted by Daniel D on
Thank you Don!

You are absolutely right, it was wrong referential link from index.tcl.

Thank you again!

Daniel