Hi Duncan,
yes, setRequired has been introduced after 2.1.7, i believe it's in 2.1.8. Unfortunately there is no way to set a widget required or not dynamically in 2.1.7. You could :
- Upgrade to 2.1.8
- Take the 2.1.8 field (o.a.c.forms.formmodel.Field) source (together with builder and definition), and patch only those fiels in your 2.1.7 (this could work).
- If you cannot patch cocoon, take the 2.1.8 field (same, Field, FieldDefinition and FieldDefinitionBuilder) sources, repackage them in a package of yours (eclipse refactoring can help) and then change cocoon.xconf so that does not use the default Field but your Field (which is 2.1.8 one). Haven't tested this myself, but with a bit of work should do the trick.

Hope this helps.

Simone

Duncan McLean wrote:
Hi Simone

Thanks for that, but we tried using "widget.setRequired(true)" but it
reports that "setRequired is not a function".

We are using Cocoon 2.1.7 - is this the problem or is it something else?

Thanks

  
Hi Duncan,
If you are talking about server side _javascript_ (like flow or
fd:on-value-changed) then you can use the setRequired(true) on the
widget(s) you want to make mandatory. In this case, you have to set the
fd:on-value-changed in the radio buttons definition, with a
fd:_javascript_ inside that makes all the needed checks and then looks up
the widgets and calls widget.setRequired(true) on those that must become
mandatory when a certain radio button is selected.

Also, if it does not happen automatically, set a fi:styling
submit-on-change on those radio buttons, to make sure the form will get
automatically submitted when the user selectes a radio button.

This techique will cause a page reload, you can make this less annoying
for the user using ajax.

Hope this helps,
Simone




Duncan McLean wrote:

    
Hi

Does anyone know how to set a field as required from within a _javascript_
block in a field definition?

We have a set of radio buttons, and depending on which one is selected
this will influence which subsequent fields are compulsory.
We've tried to set the "required" attribute of a particular field, but
this has no effect.

Anybody have any code which does this, or is it impossible?

Thanks

Duncan



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



      
--
Simone Gianni

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



    



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

  
--
Simone Gianni

Reply via email to