I have a form with a few singular fields and a repeating panel. I have validation methods for the regular fields, and I can trigger them on update, on lose focus and when hitting the submit button. I have validation methods for the fields within the repeating panel too, and although I can trigger them in events within the repeating panel, I can’t seem to be able to trigger them from the main form (e.g. when the main form’s submit button is pressed).
Simple example:
class MainForm(MainFormTemplate):
...
def validate_foo(self, **event_args):
if len(self.foo.text) == '':
self.foo.border = '2px solid red'
return False
else:
self.foo.border = ''
return True
and
class RepeatingPanel(RepeatingPanelTemplate):
...
def validate_bar(self, **event_args):
if len(self.bar.text) == '':
self.bar.border = '2px solid red'
return False
else:
self.bar.border = ''
return True
I want to be able to call the validate_bar
method from the main form, but as far as I can tell the instance of RepeatingPanel
isn’t accessible from MainForm
.
I want to do something like this:
class MainForm(MainFormTemplate):
...
def on_submit(self, **event_args):
valid = all([
self.validate_foo(),
all(bar.validate_bar() for bar in self.bars)
])
if valid:
alert("OK")
else:
alert("Errors")