Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

access parent form's cleaned_data from inline form clean()

I have a main form that has an inline-form. Is it possible to access the main form's cleaned_data from the inline-form's clean function?

Here is why I am asking.

The main form has a field to define if a property is for-sale or to lease. The inline form then displays either a sale price field or fields for the lease amount and deposit. I am trying to validate that if the property is for sale, then the lease and deposit fields should be empty.

I can do this in a view for the frontend interface, but is it possible to be done in forms.py for both the frontend and the admin?

like image 394
bmeyer71 Avatar asked Apr 16 '12 23:04

bmeyer71


1 Answers

No, these forms are separate objects and are completely unaware of each other. But you are providing same data to all forms, so you should be able to check fields from self.data.

like image 117
ilvar Avatar answered Nov 19 '22 08:11

ilvar