Forum OpenACS Development: ad_form, formtemplate, radio buttons

Collapse
Posted by Chris Davies on
well, after browsing a bunch of docs, a bunch of helpful pages, a ton of source code, I've come across something I just cannot figure out and I'm at a total loss.  I have 99% of things working the way I want, except, for setting the radio button's 'selected' value.

{requiredhits:integer(radio),optional
  {options {{3 3} {4 4} {5 5} {6 6} {7 7} {8 8} {9 9} {10 10} {11 11} {12 12}}}
  {value 4}
}

This works fine when I use <formtemplate id="form"></formtemplate>

however, that doesn't give me the display I am looking for, so I've opted to define the entire form myself.

<formwidget id="requiredhits">

If I use that, it creates 1 radio button with a value of 4, but no other radio buttons.

I've tried other incarnations, i.e.

<formwidget id="requiredhits:4">

or id="form:element:requiredhits:4" and a few others, but that doesn't do it.

<formwidget id="requiredhits" value="5">

returns a rendered page that has two value statements -- which of course doesn't work properly.

I've tried looking for extra parameters in the source, but honestly, cannot figure out what that piece of the code is doing.

I've also tried hacking things together with adp and <if>, to no real avail.

I know I'm probably missing something very obvious -- can someone point me in the right direction?

Collapse
Posted by Andrei Popov on
I think that you aren't expected to use formwidget outside the template definition i.e. outside of /packages/acs-templating/resources/forms/foo-bar-baz.adp.  And there you'd have to have it as part of a multiple.  I may be mistaken though.  What are you intending to do, btw?  What part of standard ad_form rendering does not satisfy your need?  How about using CSS to solve it?  By having a {html {id requiredhits}} added in .tcl and designing a stylesheet to layout RADIO#requiredhits differently from normal RADIO?
Collapse
Posted by Dave Bauer on
Chris,

Look in acs-templating/resources/forms/standard.adp to see how it handles radio and checkbox groups. You need to use the formgroup tag.

Collapse
Posted by Chris Davies on
Andrei,

In this case, I wanted 12 radio buttons in a row rather than a column.  I didn't want to alter the defaults for every form, just for this one form.

Dave,

<formgroup> worked like a champ -- I looked at that about 10 times this weekend and just couldn't get it to work.  After a few hours of sleep and your suggestion, it works.  Thanks!

Collapse
Posted by Andrei Popov on
<blockquote> I didn't want to alter the defaults for every form, just for this one form.
</blockquote>

And this is exactly what you probably could achieve with CSS (by setting them to be "inline" rather than "block").  The current formtemplate (that uses TABLE to layout all of these elements) would not however allow you the full control.

Anyway, you seem to be all set now.

Collapse
Posted by Jon Griffin on
I uploaded my css to replace the form template.
http://jongriffin.com/static/openacs/css-only/
You will have to dig through it as the page isn't complete yet, but it will get you going in the right direction.
Long Live CSS... finally.