Forum OpenACS Q&A: Setting properties in form's elements

Hy all,
I need to set dynamically a property in a form element.

AFAIK both the 'element::create' and 'element::set_properties' API accept a key-value pair wich is perfectly suited to manage properties like foo=bar, but I can't find a way to set a single word property like 'readonly'.
Any ideas?

TIA, Claudio

Collapse
Posted by Ernst Guenter on
Hi!

I faced the same problem. I simply supplied an empty string for value (see example). This worked fine for me.

template::element create main shortname -datatype text -widget text -html {size 70 readonly ""} -label Shortname

EG

Collapse
Posted by Claudio Pasolini on
Thank You very much, Ernst!
Collapse
Posted by Don Baccus on
The ad_form version:
ad_form -name main {
    {shortname:text    {label "Shortname"}
                       {html {size 70 readonly ""}}}
}
(it uses the form builder as its backend).

The biggest advantage of ad_form is that it handles all the state management (submit, request, etc) for you.