Hi Robin
We had thought about doing custom validation for this, but the
requirement says that the asterisk that denotes a mandatory field should
show up if the field in question was required.
As I understand it, custom validation wouldn't give us this...unless
there is a way we could "fake" this if we use custom validation?
Thanks again
Duncan
Robin Wyles wrote:
Hi Duncan,
An alternative perhaps would be to use custom validation either on
your form object or on the fields on which you wanted to set the
required. The custom validation could just look at the values of the
your radio buttons and then decide whether the field in question
should be filled in. I'm pretty sure this is supported in 2.1.7.
Regards,
Robin
On 17 Feb 2006, at 18:28, Duncan McLean wrote:
Hi again
Thanks for the advice - looks like we make take the 3rd option as
this looks the most workable for us at the moment.
Duncan
Simone Gianni wrote:
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
---------------------------------------------------------------------
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]