How to add dynamic clean_ fields
Closed this issue · 0 comments
marr commented
I am constructing my form fields dynamically, and have some fields i'd like to add dynamic clean methods for. I've overridden constructor
for the form and create the fields with a high order function like this:
function createCleanQuestionField(questionFieldName, optionFieldName) {
return function() {
if (!this.cleanedData[questionFieldName] && this.cleanedData[optionFieldName]) {
throw newforms.ValidationError('Must enter a question if you have options!');
}
}
}
is something like that possible?