Answer the question
In order to leave comments, you need to log in
Different types one form?
Help solve the problem...
There are 3 types of material
News, Article, Video
All three have essentially the same fields, but each has 3-4 different fields specific only to a certain type.
Since I have a type choice in Post, respectively, and there is only one form, but dumping all this into one form is crazy.
And there was a problem with validation. For example, I fill in the news type and I don’t need the test fields, it is needed for the Video type, and it is written in the validation that it is mandatory.
How to make it so that when choosing a type there would be only the necessary fields and validation of these particular fields?
Or as an option to divide it all into 3 different forms.
For example, create /news/add and make a type selection in the view, if the type is news, then we render the news form.
How to help me decide.
Answer the question
In order to leave comments, you need to log in
Don't make life difficult for yourself. Divide into different models, and common fields during rendering can be moved to partial.
It is better to spread the KMC into different classes and can be derived from the base class if necessary.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question