I have an Input inside of a Block which is inside of a Form.
When I submit the Form it becomes invalid if the input is blank and mandatory which is great.
However, I have a few custom validation (e.g. the value in the input must be greater than 200) and when I run those custom validations in the submit button logic and then manually set the Input.valid property of those inputs to false if invalid, the Form stays valid.
So when an Input is inside of a Block it seems to change the functionality/consequence of manually setting the inputs validity on the outer Form. I personally did not expect this...
Is this the expected behaviour, and if so - why, and is there a way around this as I would like this automatic form invalidation to stay consistent.
Hi @Nicholas Campbell,
I was just trying to reproduce to come up with a workaround, but i'm not really following what exactly you are doing :
Anyway, regardless of what you are doing, invalidating an input in a block does not trigger the enclosing form to be invalidated, I think that's probably wrong / a bug ?? But maybe it is not considered a very likely usecase and too much work, or something, that's for someone of Outsystems to answer.
Dorine
Hi @Dorine Boudry thanks for validating this for me.
It is a bit of a strange use case yes but quite frustrating that it does not work as expected. It is for a custom reusable component I am building. I am using JS to trigger the invalidation of an Input inside the component - it is just one input in the component, but the component will be inside a Form on my screen amoung other inputs - so I want the invalidtion of the input inside of my component to invalidate the enclosing Form just like doing so for any of the normal inputs would do.
yes,
it is odd that it doesn't work, but i doubt this is a common enough use case to do something about it.
As a workaround, you could put a dummy display:none input on the parent form, and invalidate that one whenever the one in the block is invalid. I would try to set it up as an invisible input in a placeholder on the block, so wherever you put the block, it is also automatically there.
Hi Dorine
Thanks for the workaround. Although I agree this would work, it would be very strange for other developers to try use. So I am going to rather just invalidate it manually for now and hopefully OutSystems can fix this issue... not super helpful though.