Home
The Toolkit for Online Communities
15903 Community Members, 0 members online, 2477 visitors today
Log In Register

Forum OpenACS Development: ad_form vs. template::form vs. roll your own

OpenACS Home : Forums : OpenACS Development : ad_form vs. template::form vs. roll your own

Icon of Envelope Request notifications

Two queries:

I'm working on a package where I cannot get ad_form to render the page in a way that makes sense.  Simply put, I want the radio buttons to go across the page wrapped with some HTML to make the presentation more intuitive to the user.

I looked at template::form, and while it does allow more overall control, I still end up with a form that I cannot render as much as I would like.

If I roll my own, I can get the page to look exactly how I want, but, I lose out on some of the strengths of using the built in methods.

Any suggestions?


I run into another issue that I don't know quite how to handle.

I have 15 rows of data in Postgres, but again, for user aesthetics, I cannot figure out how to make this work using ad_form or template::form.

Basically I pull the data using a multirow, but, I want each line to be its own 'form'.  I don't care if I have 15 submit buttons to allow a change and it calls one form, or if I have 15 forms.  A simple diagram is here.

[select pulldown] ___________________    [save] [Delete]


The obvious benefit to having it be one form is that changes on multiple records aren't lost when they hit save, but how do I get ad_form to output and handle 15 rows from SQL? or is this more a job for template::form?

Thanks.

+
Posted by Jon Griffin on
Why don't you just change the template in acs-templating/resources?
I have a complete CSS version I use for all my forms and then you can change layout anyway you want.
+
Posted by Chris Davies on
Can I change the template on one form only?
+
Posted by Don Baccus on
Yes, you can, just create a new one that does what you want then reference it in the formtemplate tag.

Or ... you can create the form directly using the various form tags.  This is a roll-your-own approach to the problem, but within the form template system.

Both work with either ad_form or the generally more awkward form::template stuff.

+
Posted by Don Baccus on
It is easy enough to build a single form with multiple rows as you describe.  Just use the -extend form of ad_form to add each select widget for the rows as you step through them.
+
Posted by Tilmann Singer on
Creating your own layout within the templating system as Don said works like this:

<formtemplate id="myform">
some html stuff ...<br><br><br>
<formwidget id="mywidget1" size="20" ...>
...
</formtemplate>

As soon as the contents of the formtemplate tag are not empty it will use those to render the form instead of rendering it automatically.

+
Posted by Chris Davies on
That was the piece I was missing.

I had done that, but wasn't reading the error message in the logs correctly.

formbutton:ok  :)

I was missing the :ok on that widget.

Thanks for the help everyone!

+
Posted by Jade Rubick on
You can look at the add-edit form from project-manager as an example of this. It has a lot of extraneous hacking in it too, so that might confuse, though. But if you look at the .adp page, that shows the important part.