Jeremy Quinn dijo:
> I have a booleanfield widget, that needs to be disabled under certain
> conditions.
>
> pseudo-code :
>
> if ( album.scenarios.size() > 0 ) {
> disable ( album.publishable );
> }
>
> ie. the album.publishable value needs to be in the form, but should not
> be alterable by the user.
>
> Is there a way of doing this in Cocoon Forms ?
Hi Jeremy:
In short, no. Also a roundtrip to the server to do this is not the best
idea. I think the problem is similar as when we needed to make some
"calculated widgets". We solved the problem in this way:
1-call a JS function in the OnLoad event of your page to initializate any
state of the controlled widget.
2-Add a onChange event on "album.scenarios" that will check for size and
turn on of off the "album.publishable" control. The JS code can be quite
similar to this code:
function toggleControl(id) {
var element = document.getElementById(id);
with (element.style) {
if (display == "none") {
display = ""
} else{
display = "none"
}
}
}
AFAIK, you will need to change the woody.xslt to allow the usage of OnLoad
event in the <body> of your HTML page.
As a example in the template I wrote:
<document menu="true" js="activity/client.js" onload="atStart();"
...
<td>
<wt:widget id="pcd_quantity">
<wi:styling size="10" OnChange="calculateTheOtherWidget(this);"/>
</wt:widget>
</td>
...
</document>
BTW, because using clientside JS is very easy when we have id's on every
widget. I suggested to include id's even when rendering the <wd:output>,
but seems like nobody want it and proposal was forgotten. :-(
Hope this help.
Best Regards,
Antonio Gallardo