41
Views
10
Comments
Form validation not working when inside Block on Tabs
Question
Application Type
Reactive

The best way to describe the problem is to show it...

In the following page: https://odc-community-l145-dev.outsystems.app/TestApp/Page1
I've created a form containing a required input and a button that triggers built in validations which works fine:

In the following page: https://odc-community-l145-dev.outsystems.app/TestApp/Page2 
I moved the form inside tabs, which continues to work:

In the following page: https://odc-community-l145-dev.outsystems.app/TestApp/Page3
I moved the tabs to a new block and simply use the block in the page (instead of having tabs directly in the page) and...

Clicking Save, nothing happens. 

Any clue?

Thanks

TestApp.oml
2016-04-22 00-29-45
Nuno Reis
 
MVP

Hello.

So you have the inputs in a block and that block inside a form?

I've never done and I assume it doesn't work:


A block can have multiple instances on the same page. If means the same input would exist multiple times in the same form!

Form validations assume that the form has knowledge of all the inputs inside so it can edit the ValidationMessage, and see the widget.IsValid to determine the form.IsValid.

If you want the inputs to be on a block, the form must be in that block.



2023-08-29 05-15-27
Navdeep Gupta

If you're placing inputs inside a block and then wrapping that block inside a form, it may not work as expected.

The reason is that a block can have multiple instances on the same page, meaning the same input fields could exist multiple times within the same form. This creates issues with form validation because:

  1. The form expects to have full knowledge of all inputs to correctly display validation messages.
  2. The ValidationMessage and widget.IsValid checks are tied to the form, ensuring form.IsValid works correctly.

If you want inputs to be inside a block, the best approach is to keep the form within that block rather than placing the block inside the form. This ensures the validation logic remains intact and works as expected.

2025-03-11 17-46-55
Tiago Dias

To clarify previous answers:
Page contains the Block (nothing else):

And the Block contains the form inside a TAB:

Button simply:

2021-09-06 15-09-53
Dorine Boudry
 
MVP

Can't open your file.

Tried it myself and I don't get the same problem

2025-03-11 17-46-55
Tiago Dias

I'm facing the problem in ODC not OS11

2021-09-06 15-09-53
Dorine Boudry
 
MVP
2025-03-11 17-46-55
Tiago Dias

Hi @Dorine Boudry,

I noticed that you have "form in block in tab" and this is different from what i have "form in tab in block"

I also recreated what you described (form in block in tab) here: https://odc-community-l145-dev.outsystems.app/TestApp/Page4

and it works.
But this is not the scenario i want.

Thank you to keep looking into this.

2021-09-06 15-09-53
Dorine Boudry
 
MVP

Ah, yes, I got that wrong.

I can now reproduce the problem, and agree it must be just one render not happening.

The validation is getting executed, and as soon as I start typing, the validation message does appear.

I agree this is a bug / oversight, @Gonçalo Martins : is this for the platform or for the OutSystems UI team ??

A workaround, is to add the validation message in an expression with style display:none, that forces a render.

Dorine

2025-03-11 17-46-55
Tiago Dias

I have new findings on the problem.
I believe the problem might be related to a missing render when content lives inside placeholders.

Why?

1) I recreated a block with tabs behaviour using containers and placeholders, and i ended with the same problem;

2) Please open : https://odc-community-l145-dev.outsystems.app/TestApp/Page3
    then click 'Save' (no message will appear)
    then input something in the input and you'll see that the error message will appear:

2025-03-11 17-46-55
Tiago Dias

New OML Version 

TestApp.oml
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.