Forum OpenACS Q&A: How to customize ad_form's HTML

Posted by Mattia Righetti on
Hello everybody,

I know that with OpenACS 4 there was ad_form and, in the adp file, the form wasn't build automatically but you had to code every field of the form. Instead now just put <\formtemplate\> and it's done by itself.
I always used that, but now i have the need to customize the form and put, for example, two filelds on the same row instead of one on top of the other.

Does anybody have some examples?

Thank you in advance,
All the best.
Posted by Bjoern Kiesbye on
Hello Matia,

you can place the widgets created with ad_form in your adp file, using the Tag <formwidget id="element_name"/> for single inputs like Textfields, and <formgroup id="element_name"></formgroup> (which is like a <multiple name="..">) for sets of inputs like Radio Buttons or Checkboxes. To display a widgets error message, if for example a data type check failed after the form was submitted, place <formerror id="element_name"></formerror> into the adp. All widget Tags must be nested within the <formtemplate id="your_form"></formtemplate> Tag of the form they belong to.

here is a little example:

<formtemplate id="order_form">
<formwidget id="ac_email">
<td colspan="2" align="left">
<font color="red">
  <formerror id="ac_email"></formerror>
<td align="left" colspan="2">
MESSAGE KEY MISSING: 'accommodation.order_register_for_news_letter'
<formgroup id="ac_news_check">@formgroup.widget;noquote@</formgroup>

I hope this helps,