Forum OpenACS Development: Rendering input type checkbox with template::element::create

Hi there,

I 'm having troubles on rendering input type checkbox with template::element::create

The following ad_proc [tempalte::element::create] for a checkbox widget responds differently deppending on the context it's in

template::element::create $form_id milestone_p \
-datatype "text" "" \
-widget checkbox \
-label "Release Item" \
-options "{\"\" t}" \
-custom "" \
-html "" \
-after_html "" \
-mode edit

When placed within an ad_proc { ... } it returns the html chunk as in

<input type="checkbox" name="release_item_p" value="t" id="project_filter:elements:release_item_p:t" > <a href='/intranet-dynfield/attribute-new?attribute%5fid=29046&return%5furl=%2fintranet%2fprojects%2findex%3ffilter%255fadvanced%255fp%3d1%26return%255furl%3d%252fintranet%252fprojects%252f'><img src='/intranet/images/navbar_default/wrench.png' border=0 title='' alt=''></a>

On the other hand when placed directly within a .tcl page, it returns the html chunk as in

input type="checkbox" name="milestone_p" value="t" id="project-ae:elements:milestone_p:t" a href='/intranet-dynfield/attribute-new?attribute%5fid=29046&return%5furl=%2fintranet%2fprojects%2findex%3ffilter%255fadvanced%255fp%3d1%26return%255furl%3d%252fintranet%252fprojects%252f' img src='/intranet/images/navbar_default/wrench.png' border=0 title='' alt=''/a

I wonder what could be different on the context they are called.
Any enlightening ideas would be very welcome!

OACS forums are trick in the same way rendering html tags

In order to replicate the bug here in this thread I put the tags and its codes between quotes. That way I can better clarify what errors I got

When I place it within an ad_proc I got the html tags converted to their correspondent entity code

"<"input type="checkbox" name="release_item_p" value="t" id="project_filter:elements:release_item_p:t"""">" "<"a href='/intranet-dynfield/attribute-new?attribute%5fid=29046&return%5furl=%2fintranet%2fprojects%2findex%3ffilter%255fadvanced%255fp%3d1%26return%255furl%3d%252fintranet%252fprojects%252f'">"<"img src='/intranet/images/navbar_default/wrench.png' border=0 title='' alt=''">""<"/a">"

On the other hand when placed directly within a .tcl page, it returns the correct html chunk as in

<input type="checkbox" name="release_item_p" value="t" id="project_filter:elements:release_item_p:t" > <a href='/intranet-dynfield/attribute-new?attribute%5fid=29046&return%5furl=%2fintranet%2fprojects%2findex%3ffilter%255fadvanced%255fp%3d1%26return%255furl%3d%252fintranet%252fprojects%252f'><img src='/intranet/images/navbar_default/wrench.png' border=0 title='' alt=''></a>

Hi Iuri

I'm not sure if the forums here have mangled your HTML, or if in fact, that's the problem you're trying to report with your widget!

One thing I noticed about your widget is that I would normally write the -options like this:

-options {{"" "t"}} \

I don't see why you have to escape the double quotes.

Brian

Brian,

Yes, the forum has mangled the HTML I tried to describe.

Basically, what I tried to show here is that depending on the context the ad_proc [template::element::create] changes its behavior for checkbox input type.

I mean, if I call [template::element::create] directly on a .TCL page it works fine. However, if I call it within an ad_proc as in:

ad_proc -public iuri::append_field_to_form { ...} {
...
template::element::create $form_id milestone_p \
-datatype "text" "" \
-widget checkbox \
-label "Miletone" \
-options "{\"\" t}" \
-custom "" \
-html ""
...

the html page in the end doesn't recognize the input element as an html tag and it displays as in

"&lt"input type="checkbox&quot name="release_item_p" value="t&quot id="project_filter:elements:release_item_p:t"""">" "&lt"a href='/intranet-dynfield/attribute-new?attribute%5fid=29046&return%5furl=%2fintranet%2fprojects%2findex%3ffilter%255fadvanced%255fp%3d1%26return%255furl%3d%252fintranet%252fprojects%252f'"&gt"&lt"img src='/intranet/images/navbar_default/wrench.png' border=0 title='' alt=''"&gt""&lt"/a"&gt"

The feeling I had was like a "noquote" was missing as in @tcl_var;noquote@ but [template::element::create] doesn't return anything it just writes the HTM code along the page. *if you know what I mean

I also try to use ad_return_template but it didn't work either.

Any clues?

The forums mangled again and I don't have a way to write

Changes the signs < > " " for its correspondent codes lt; quot; with the & in the bigining

:) hope I could make myself understandable!

Hi Iuri

yes I understand the problem now. I imagine it's a problem of the scope in which you call your proc. My guess is that you are returning the generated HTML in your proc somehow, instead of allowing the form builder to do it for you.

There are plenty of examples already in OpenACS of calling template::element create from a proc. If you're using Project Open, take a look at DynFields; I know it's done there.

best wishes
Brian