-
-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #136 -- Add dependent-field support to formsets #231
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Ombental,
Thank you for your contribution. I appreciate your help. It looks like a promising start. I left you a small suggestion. Besides that, I'd appreciate it if you could add a test. The selenium setup is a bit tricky. Don't hesitate to ask for help, regarding the tests.
Cheers!
Joe
var formValue = $('[name=' + dependentField + ']', $element.closest('form')).val(); | ||
// This is for inlines, I checked this for a specific case | ||
if (formValue === null || formValue === undefined) { | ||
var newFieldName = $element[0].name.split('-', 2).join('-') + '-' + dependentField; | ||
var formsetValue = $('[name=' + newFieldName + ']', $element.closest('.form-row')).val(); | ||
result[dependentField] = formsetValue; | ||
} else { | ||
result[dependentField] = formValue; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe you can simply this a little and drop the else branch, like so:
var formValue = $('[name=' + dependentField + ']', $element.closest('form')).val(); | |
// This is for inlines, I checked this for a specific case | |
if (formValue === null || formValue === undefined) { | |
var newFieldName = $element[0].name.split('-', 2).join('-') + '-' + dependentField; | |
var formsetValue = $('[name=' + newFieldName + ']', $element.closest('.form-row')).val(); | |
result[dependentField] = formsetValue; | |
} else { | |
result[dependentField] = formValue; | |
} | |
var formValue = $('[name=' + dependentField + ']', $element.closest('form')).val(); | |
// This is for inlines, I checked this for a specific case | |
if (formValue === null || formValue === undefined) { | |
var newFieldName = $element[0].name.split('-', 2).join('-') + '-' + dependentField; | |
formValue = $('[name=' + newFieldName + ']', $element.closest('.form-row')).val(); | |
} | |
result[dependentField] = formValue; |
This is great and solve our problems. Looking forward a release |
I labeled this as minor because I didn't take into consideration all use cases but my private one, though I do think it answers most of the needs. this is django admin oriented