22
Views
2
Comments
Solved
Validate Form in different webblock
Question

Hi! 

I have a question regarding the validation of a form. 

My application is basically a questionnaire that has 10 questions. The questions are inside a webblock with a list that gets all the questions. The multiple choice questions have their own webblock with the answer options etc. 

Everytime a question is changed (onchange or onBlur event) there is an action running to append the answer to a list. This happens via an Event that pushes the data up trough the webblocks. In the top webblock the data is appended in a list. This local list is later used as input for a save action that will save all data at once. If a user clicks the Save button I want OutSystems to verify if all the questions are answered and if the entered data is the expected format. So I have added a form and put my questions list in here. 

Is there a way to go through the webblocks and execute the FormValid validation? 

My current structure looks like this: 

Webscreen Questionnaire
                       Web block QuestionList (1)
                       Web block QuestionData (2)
                       Web block QuestionOptions (3)

In each web block there is an Event Handler that pushes data up to its parent web block or screen


My first idea was to use the WidgetClick action that will click a button (that is inside the form with questions in the webblock (2)  that will validate if the form is valid or not. If not valid the action should be 'aborted' and the save action should not be executed on the first webblock (1). If the form on the second webblock is valid, the same should happen for the multiplechoice webblock (3). If this is Valid a boolean variable should be set to TRUE and this should ultimately execute the save action.

I am not sure if this works and if there is a way to execute this kind of logic. So if anyone has some ideas, please share with me! 


Thanks,
Max


Rank: #10286
Solution

Hi Eduardo, 

Thanks for you reply.

I have already found the answer.

By placing the second webblock (2), that lists all the questions, in a form  in the first webblock (1),  the input can be validated through the use of the validation property of a button! 

Hi, when i needed to use an input with validation in a webblock, i put an input parameter to set if it was valid and the message.

Rank: #10286
Solution

Hi Eduardo, 

Thanks for you reply.

I have already found the answer.

By placing the second webblock (2), that lists all the questions, in a form  in the first webblock (1),  the input can be validated through the use of the validation property of a button!