I need to do a form that changes on-the-fly depending of a choice
The way I'd approach this is to have optional fields for both the month and year pickers, but use Javascript to hide the one you don't want the user to see based on the value in the payment type. Then, in the clean method of the form, I'd validate that correct field was filled in (maybe raise a ValidationError if the both were filled?).
Alternatively, depending on what you're actually storing as a result from the datepicker (just the year or month?) maybe it'd be simpler to just dynamically update the datepicker's configuration based on the payment type field's value.
It's a little tricky to give you more specific suggestions without having more information about how you've setup your code.
The form that I need to do is for the user to select a payment type.The problem is that depending on the choice if the user wants to pay monthly or annually a different date-picker field has to appear. if he selects monthly, he has to choose a day of the month. And if he chooses annually a date-picker that allows him to pick the month has to appear.
I've been searching online for an answer but all I can find is dynamic form in the sense that it can generate a field type multiples times and that is not what I need.
All help is appreciated.