Forum OpenACS Development: listbuilder - pre-checking some checkboxes?

Hello all,

First: listbuilder rules, thank you.  Being able to produce really NICE looking tables with so little typing is wonderful. :)

Second: A question.  Is there some straightforward way to pre-check some of listbuilder's checkboxes?  I'm pulling rows out of the database and would like to check some of them based on a value pulled from the db.  Feel free to point me at a package that does this already if one exists.  I've looked at the docs (thanks Jade) and api-doc but am not seeing anything that seems to do what I want.

Thanks!

/Cathy

Collapse
Posted by Vinod Kurup on
I know this post is 2 years old, but I just had the same question and found 1 way to do it, so thought I'd post it here for the next wanderer...

First, set -has_checkboxes which tells the listbuilder that you will create your own checkboxes.

Then, in the -elements section, create an element like this:

-elements {
  checkbox {
    display_template {<input type="checkbox" name="yourlistkey" value="@yourmultirow.yourlistkey@" @yourmultirow.checkbox@ />}
  }
...
}
Then, extend your multirow with the 'checkbox' variable.
db_multirow -extend {checkbox} yourmultirow .... {
  if { $my_criteria } {
    set checkbox "checked"
  } else {
    set checkbox ""
  }
}
Replace yourmultirow with the name of your multirow.
Replace yourlistkey with the listkey column of your list