sdk 3 - mandatory field only for one option

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Established Member II

sdk 3 - mandatory field only for one option

Hi,

i have form with different buttons (options) :

I don't know how to add controls on fields in order to resolve following case :

- field 1 must be filled out for option A but not for option B, etc...

I have put <mandatory> tag in my model xml file but the field must be filled out whatever the option choosed....

Thank you

5 Replies
Highlighted
Senior Member II

Re: sdk 3 - mandatory field only for one option

You need to customize the form field,For this kind of mandatory fields you can use validation handler.

Below link will help you in develop the same thing.

Form Field Validation Handlers | Alfresco Documentation 

In above link if you look at java script function , there are few function arguments which will help you in getting the values of other fields as well.You can determine the validity of the field based on this values.

Highlighted
Established Member II

Re: sdk 3 - mandatory field only for one option

Hi,

I follow the tuto but i have the following error :

TypeError: MyCustomNamespace.forms is undefined"

This is what i have done :

workflow config file (share):

js file :

console message :

conflict ?

Thank's

Highlighted
Senior Member II

Re: sdk 3 - mandatory field only for one option

MyCustomNamespace.forms.validtion.checkFields is not defined.

In you javascript file, if you check first few line in that case it is defining the MyCustomNamespace variable,but what about MyCustomNamespace.forms.

MyCustomNamespace.forms is null, so when you try to access MyCustomNamespace.form.validation it will give error.

You can just define it like MyCustomNamespace.checkFields= function................................

Highlighted
Established Member II

Re: sdk 3 - mandatory field only for one option

Exact ! Thank you

But now i get "TypeError: YAHOO.lang.trim(...) is undefined"

i may have missed a step

Highlighted
Established Member II

Re: sdk 3 - mandatory field only for one option

Ok this is what i have done :

there are 4 buttons to submit the form

The control is only installed for one button (but even if i click on the others,  this control starts.....)

checkFields function :

when i click on the button "reviewOutcomeDem" (whith validation-handler) :

I can check fields value before submission but i can't check wich button has been clicked (i can but after submission as you can see on log)

Moreover the click event is called 2 times !!

If i choose an other button i have same problem :

The aim is to check some values depending on the button clicked

How can i do  ????