P
P
pantsarny2015-01-30 12:28:20
Yii
pantsarny, 2015-01-30 12:28:20

Yii - how to validate rules depending on the module?

Good afternoon, dear users. A Yii project is created, there is a modular structure - frontend, backend, api, etc... It is necessary to validate model attributes depending on the current module. I explain with an example. If a post is created from the frontend, then it is automatically necessary to set the id of the current user in the user_id, but if it is from the backend, we have the right to specify any user. In practice, I met 2 approaches, this is the definition of the base ModelBase model and the inheritance of the model from it in the module with its own rules, and the creation of a common model with frontend, backend scripts and specifying the script when working with the model. Please give advice on how best to proceed and how you define validation rules in projects like this. Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
LIAL, 2015-01-30
@pantsarny

Use scripts IMHO a more correct solution

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question