Where to validate and process form submission in MVC website

前端 未结 3 987
既然无缘
既然无缘 2021-01-03 14:09

I\'m working on a PHP based Model-View-Controller structured website. I understand that the Models should deal with business logic, views present HTML (or whatever) to the u

3条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-03 14:42

    From my point of view and the way we're doing it at work, model will handle the validation and filtering of datas that are passed to it, but we use the controller to push thoose datas inside the model.

    Has stated in above comments, the model don't have to know about $_POST or $_GET these are user input that the controller has to deal with. In the other hand the model must handle all verification of datas passed to it as you definitely don't want to make again and again your data validation in different code portion of your project.

提交回复
热议问题