Closed Darayavaush closed 6 years ago
Write custom validation code. Giving access to the parent form sounds like bad software design.
What do you mean? I am trying to write custom validation code. Where do you suggest I put it?
This is an issue tracker for changes to this code package, not a place to ask questions for help. Stack Overflow etc. is the proper place for that.
That said, you could override ProcessFormWithInlinesView.post()
as it calls self.construct_inlines()
after the main form has been validated. If it was me, I would also override construct_inlines()
to take a parameter based on the parent form's checkbox and use it to determine which Form class should be used for your inline formset (assuming there is only one). One available Form class would have extra validation, the other would not.
This would be fine for your custom code but is obviously not something we would include in this software package, as jonashaag said.
I need to implement the following logic: when a checkbox in the parent form is checked, make sure that a certain field is not empty in every form in attached formset, otherwise fail validation. However, judging by the code of ProcessFormWithInlinesView:post(), the parent form and every formset are completely isolated when being cleaned, which makes this impossible, as far as I can tell.