C
C
Crash2017-03-02 10:44:57
Yii
Crash, 2017-03-02 10:44:57

How to make form fields required without specifying the rules in the model?

There is a model for working with a specific table in the database. It defines additional fields for one of the forms. This model is used simultaneously in 2 versions: in the form with additional fields and in the form without them (ActiveForm). For additional fields, I need to specify that they are required (attribute required). But I can't do it in the rules, otherwise in the 2nd case the form cannot be saved. How it is possible to make fields obligatory "on the fly" not to crutch once again? What are the options for this and how to use them in ActiveField?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2017-03-02
@slo_nik

Good morning.
In this case, scripts are used.
Specify which script to use for which case. And in the first case you check additional fields, in the second you do not check them.
Read more here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question