Closed khatchad closed 3 years ago
Since we added the fields that are for adding new categories, causes, symptoms and fixes. We can only control for the field that is from the ModelForm
to be required. That is why if you enter the form incorrectly and it doesn't insert then you will be required to use the ModelForm
field. For example, if I am filling in the form and I put a problem category but I forget to add a problem cause, symptom and fix. You cannot add a new cause, symptom or fix for these, you would need to put a previously existing field since that is put as required. I have that code available but I wanted to speak about that issue before committing. I can give screenshot of the scenario if necessary.
Can you add to agenda?
Of course.
Cannot reproduce on a4da54a41d158c8c0e36c3f97c33478774a4dd28.
Did some more testing. If we leave the problem cause (which is the second category) blank, then the categorization row gets inserted with a missing problem cause.
@khatchad Do you want the problem cause or the problem category to be required? Or both?
First step is to reproduce this bug. Can you?
Try to recreate the problem I saw in https://github.com/ponder-lab/Imperative-DL-Study-Web-App/issues/83#issuecomment-852459914
I am able to create a category without specifying a problem cause or problem category, is this the bug that you are referring to?
Hm. Not sure I understand, Can you explain more? Also, you should verify this in your categorization list.
I created a categorization leaving problem cause and problem category blank, and it does show up in the categorizations table with those columns displaying a dash.
In summary, you have reproduced the problem?
Yeah, if I understood the problem correctly.
I encountered two major roadblocks in solving this issue.
For 1, I think this would need us to reconstruct the form and the template. For 2, I think it requires a good understanding of Django form to understanding why it is happening. I will be spending more time on them, but any help would be appreciated.
@ZhongweiL:
- The text fields for entering a new category and problem cause are not part of the model form, they are generated by the HTML in the Django template, therefore I'm not able to apply any sort of validation on them through the form class.
Right. If we keep it this way, my guess is that any validation has to be code that is not part of the form class.
This problem also applies #103
Great. Please comment there as well.
- The form is validated whenever I access the form, error messages would show even before the form is submitted.
There could be some validation performed (via JavaScript) when certain form elements are set. But, the form should not be validated as soon as it loads; some user interaction should be necessary to start validation. That would make sense to me.
For 1, I think this would need us to reconstruct the form and the template.
I believe that this isn't possible because we are allowing the user to create new field values via the form. There are examples of using Django forms to create new field values. I believe that they all combine form elements with arbitrary (template) code. You can search for those on the internet; I also think we reference some examples in the GH issues.
For 2, I think it requires a good understanding of Django form
Yes! Please become an expert on Django forms. Let me know if there are any books or other resources that you need purchased for this.
to understanding why it is happening. I will be spending more time on them, but any help would be appreciated.
What we need from you are specific questions. Therefore, please dig a little deeper and generate some ideas or alternatives and ask specific questions about them.
On the categorization insertion form, the user should not be able to create new categories that have names that are blank.