Forum OpenACS Development: Re: Too much customization to use ad_form??

Collapse
Posted by Michael Aram on
Hi Iuri,

I have just recently "upgraded" an HTML mockup with a nice looking form to a ad_form by simply

a) copy-pasting the HTML mockup "as-is" into the ADP file
b) only replacing the <form> tag by <formtemplate> and the input elements by <formwidget>.
c) adding a corresponding TCL file with an ad_form that has a simple element stub defined for each input in the form. (i.e. more or less only my_input_name:text(text),optional)

Because of the fact, that I have only used ad_form with empty <formtemplate> tags in the past (where the whole form look and feel is generated automatically), I was surprised how easy it was to get the basic functionality working. In order to provide server-side validation, I later added a handful of <formerror> tags here and there. There may be useful features of ad_form which can't be used when going this way, but for simple cases, it could be a first step for a migration.

What have you tried? What was the showstopper?

Collapse
Posted by Iuri Sampaio on
Michael, Showstoppers were TCL and ADP compatibility in a sense that ad_form didn't work hamoniously with plain HTML inputs declared in the ADP file. Matching ad_form -form elements (i.e. TCL file) with html input (ADP files) caused wether duplicity and overwriting conflicts or unawareness by ad_form. Plus, ad_form worflows didn't work as expected (i.e. edit_request, validate, on_submit, etc) As per your example, I can see now that the reason could be because I've tried b), replacing
by but without using . See example https://pastebin.com/fxGYn3dn I've used plain html inputs only. Then, I went to step c) and start coding the same html input in the ad_proc ad_form, hoping that it'd be enough to ad_form recognizes all those plain HTML inputs, present in the ADP file. That was my a mistake. Too easy to believe that would work :) I'm not familiar yet to acs-templating and formwidget tags. I'm going to get back to them, reshape ADP files, as per your example and share the results here. Thank you for sharing this case. It helped a lot to see a new perspective and how to use it, which I didn't even know it was possible. Best wishes,